The upgrade.php script provides PHP backwards compatibility. It does so by automatically defining workalikes for more recently introduced PHP 5.2 or 6.0 core functions when run in an older interpreter version (like 4.1). This allows developers or projects to safely use the more advanced features of PHP while still supporting most applications that run on outdated servers. It emulates over 100 core functions and the complete FTP, ctype, GETTEXT, and mime_magic extensions, and comes with reasonable emulations for PDO, bcmath, ODBC, and the FILTER extension.
| Tags | Software Development Libraries |
|---|---|
| Implementation | PHP |
Recent releases


Changes: This release includes PDO emulation for PHP 4.x. This new unified PHP5 standard database interface prevents SQL injection exploits if you use its prepared statements instead of error-prone string concatenation and manual escaping. Other changes include more detailed phpDoc-style comments in the main script, and file_put_contents() support for the file locking flag. The emulated json_decode() function now supports Unicode escapes and still remains five times faster than JSON.php or the Zend_Framework decoder.


Changes: Compatibility code for PHP 5.1 and 5.2 has been added. The functions json_encode, json_decode, strptime, htmlspecialchars_decode, fputcsv, and a few others are available now.


Changes: Minor fixes in the plural support code allowed merging it with the main gettext() emulation module. The bcmath extension's use of GMP and big_int was fixed, as well as its fallback changed from bc(1) to the faster POSIX dc(1) utility. Negligible fixes were made to the core script, and the README file has been slightly beautified.


Changes: The strripos() and strpbrk() functions' edge behavior has been fixed. The core script is better commented now, and some exotic functions have been moved out of it. New emulations have been added for mhash, odbc, PHP4 exceptions, and bcmath functions. The gettext module has been extended with an incomplete but extremely fast plural-forms handler (as a separate version).


Changes: Emulation code for PHP's gettext() extensions was added. Some minor additions and fixes were made, and a compact version of the upgrade.php script is included. The utility that annotates the PHP documentation with compatibility information was also corrected.
- All comments
Recent commentsPEAR::PHP_Compat
There is an alternative to the "upgrade.php" script, that already existed for a longer time. You can find it under http://pear.php.net/package/PHP_Compat (http://pear.php.net/package/PHP_Compat) and it is sometimes already installed on servers.
The emulation functions of PHP_Compat (http://pear.php.net/package/PHP_Compat) are often a bit cleaner and behave more (Warning messages) like the native ones would. It is suddenly also not complete yet, but both projects can be used in conjuction easily.