1and1 Help Centre Categories

print article

New Functions and Directives in PHP5

Advantages of PHP5 compared to PHP4:
  • Improved support of current content management systems
  • Reduced consumption of resources (e.g. RAM)
  • Increased security against exploitation of vulnerabilities in PHP scripts
  • Easier programming through new Functions, Directives and Extensions
register_globals

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 DOCUMENT_ROOT, you'll use $_SERVER['DOCUMENT_ROOT'] instead of $DOCUMENT_ROOT, or $_GET['id'] from the URL http://www.example.com/test.php?id=3 instead of $id, or $_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.

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 becomes 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

Please note:
The support of SOAP web services is a new addition to PHP5. With this version of PHP5, SQLite is not supported.

More 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.