Select Category
Sitemap Help Contact
print article

PHP4 vs. PHP5

Advantages of PHP5:
  • Improved support of current content management systems.
  • Reduced consumption of memory (RAM).
  • Increased security against exploitation of vulnerabilities in PHP scripts.
  • Easier programming through new functions and extensions.


With PHP5, the register_globals directive has been disabled. This is a major change in PHP. Having register_globals OFF affects the set of predefined variables available in the global scope.

For example, to get the document root, you'll use $_SERVER['DOCUMENT_ROOT'] instead of $DOCUMENT_ROOT and $_GET['id'] from the URL instead of $id and $_ENV['HOME'] instead of $HOME.

For more information, please reference PHP: Predefined Variables - Manual

allow_url_fopen and allow_url_include

Also in PHP5, the variables allow_url_fopen and allow_url_include remain but are disabled or turned OFF by default. This could potentially affect your PHP scripts if either of these directives need to be enabled or turned ON in order for your scripts to function properly. Unless absolutely necessary, these directives should be left disabled as it poses a slight security risk.

PHP5's New Object Model

The new object model in PHP 5 makes programming easier and more efficient. Methods can be restricted to specified user groups. Through exceptions, the handling of errors become simpler. For more information, please check PHP: Classes and Objects - Manual

XML and SOAP Web Services

XML support in PHP 5 has been updated and improved. LibXML2 has been implemented as an XML-Parser. Now, in addition to SimpleXML, PHP 5 provides a faster and easier way to manipulate XML. More information can be found at PHP: SimpleXML - Manual
The support of SOAP web services is a new addition to PHP5. Please note that with this version of PHP5, SQLite is not supported.

Additional Differences Between PHP4 and PHP5
There are other (usually) less significant changes between PHP4 and PHP5 which are documented on the PHP site at PHP: Migrating from PHP 4 to PHP 5.0.x - Manual