问题
I'm starting to learn PHP. I would like to use PHP 5.3 because it's the newest version so far. I'm working on a project in which I'll use PHP 5.2 scripts that someone gave me.
Are they going to run just fine even though I'm using PHP 5.3?
回答1:
PHP.net features a guide for upgrading from PHP 5.2.x to PHP 5.3. This includes a section on backwards compatibility.
From my experience, the transition from 5.2 to 5.3 went pretty smoothly smoothly. The only problems I had with my app was to ensure my DateTime setting were property configured in my php.ini, and filter out some overly-agressive deprecation warnings that started showing up.
回答2:
No, 5.3 is not backward compatible, and by all means it shouldn't be seen as a minor version upgrade. There is a page dedicated to incompatible changes: http://www.php.net/manual/en/migration53.incompatible.php Also consider functions you have designed but have been accepted into 5.3. Since php doesn't support overloading or overwriting of functions, this will give an error.
回答3:
For the most part, minor version releases aren't going to cause you problems. You should be okay.
Obviously, if you do have any problems, you'll want to make sure you have error_reporting
set to see all errors. PHP: error_reporting
Also, check the manual for changes in 5.3 from 5.2: Migrating from PHP 5.2.x to PHP 5.3.x
回答4:
There are some minor issues. Call time pass by reference are deprecated. There are new reserved words (ie. goto).
回答5:
php has no backward compatibility in all version. It often removed some functions when it changed version. The problem occurs when you have to upgrade server and need to change php version but some php scripts no longer work with new php version. You also have to correct php script which is a bigger job. But if the script belong to other users rather than yours, you can't upgrade those scripts. This is a real headache situation that I'm fed up with php and switch to perl instead for backward compatibility reason.
来源:https://stackoverflow.com/questions/4693575/is-php-5-3-backwards-compatible-with-php-5-2