I have a client whose has multiple websites on a server at Startlogic with PHP4 turned on by default. I installed WordPress with PHP5 dependent plugins, but whenever he turns on PHP5 support, his websites using old PHP4 programs fail. Is there a way to use .htaccess or PHP.ini for that specific folder to use PHP5 while his others sites use the default PHP4 settings? Thanks!
First, we have to install the appropriate PHP packages and their dependencies (from Dotdeb, of course) : apt-get install libapache2-mod-php5 php4-cgi Apache2 is now configured by default to parse .php files with the mod_php5 module. But, using mod_actions, we can tell Apache2 to parse .php files with the php4 CGI. First, enable mod_actions : a2enmod actions /etc/init.d/apache2 force-reload Now, by adding the following two lines in a Virtualhost or Directory (…) context or directly in the main Apache2 configuration file, we’ll switch from PHP5 to PHP4 : AddHandler php-script .php Action php-script /cgi-bin/php4 (It could be necessary to reload your apache configuration : /etc/init.d/apache2 force-reload )
If it is by default you can ask the hosting company how to turn off PHP4 and activate PHP5. I've had a similar problem in the past, I just looked through the website control panel and found a page that allowed me to turn off PHP4 and activate PHP5. BTW, PHP4 is deprecated. If your hosting company does not provide PHP5 support, FIND ANOTHER ONE. PHP4 is not supported anymore by the PHP community.
The problem is that the client has a few other websites that uses PHP4 and he is telling me that his applications break when he activates PHP5. When we activate PHP5, the WordPress site I developed for him works, but his other sites have problems. When he reactivates PHP4, his old sites work but the new WordPress site does not. That's where I'm stuck.
I guess you/he should update the old websites at the earliest convenience. PHP5 is backwards compatible so I do not think there will be any major problems. The most significant problem that I could think of (poor programming practice actually) is that that the older PHP scripts relied on the "register_globals" setting to be "On". With PHP5 it is set to "Off" by default. It can still be turned On either globally via php.ini file (not recommended) or by adding a couple of lines of code to your legacy scripts.
You are very much mistaken. PHP5 is NOT backwards compatible with PHP4. There are a lots of changes and migrating from PHP4 code to PHP5 can be a pain if the PHP4 script was coded using some reference tricks and other stuff that changed behavior in PHP5. That does not mean that PHP4 script cannot run in PHP5. It only means that PHP4 scripts are not guaranteed to run on PHP5.
http://www.php.net/manual/en/migration5.incompatible.php lists the Backward Incompatible Changes in PHP5. The list isn't long. If you're not using classes, you should not be worried too much. You major problem would be, as I said before, is your relying on register_globals=On and magic_quotes_gpc=On.
Really? Here 's a major change from PHP4 to PHP5 that 's not mentioned in the manual (you can google and verify it 's true). Regarding the default handling of function parameters, in PHP4 they were pass-by-copy unless you specified otherwise, but in PHP5 is changed to pass-by-reference by default. Depending on how lousy the PHP4 script was coded (and we all know how much lousy code is out there), this can cause a lot of subtle bugs. The script will run (no error to be triggered), but the results are not guaranteed to be the expected ones. So, in this case, you would need to do some very careful testing, to ensure the script works correctly in PHP5.
I wouldn't argue about how much lousy code is out there, i wrote lots of it myself But I can surely tell you that pass-by-reference is NOT the default in PHP5 (reference: http://php.net/manual/en/functions.arguments.php), at least for non-objects.