Differences between PHP4 and PHP5

PHP is a server-side scripting language that is used in website development. PHP4 and PHP5 are two different versions of PHP. PHP4 was first released in May of 2000. PHP5 was later released in 2004 and came powered by the Zend Engine II that is considered by the development community as an improvement over PHP4.

After various versions of PHP4, the last version titled PHP4.4.9 released in August of 2008. After the last release, it was announced that PHP4 would not longer be developed, including future security updates for the language.

With the lack of support for PHP4, many new servers are no longer supporting php4 and developers are having to make changes to their websites to support PHP5 instead of PHP4.

Here is a list of the major differences that you will notice between PHP4 and PHP5:

  • Register_globals and safe mode have been removed from PHP5 because of their ability to open security holes by allowing runtime data injection.
  • PHP5 uses Zend Engine II
  • Magic quotes as been replaced with the addslashes() function.
  • PHP5 is object oriented replacing the more procedure ordinated language of PHP4.
  • In PHP5 can declare abstract classes.
  • PHP5 uses static methods and properties.
  • PHP5 incorporated a special function called __autoload()
  • In PHP5, one can declare a class or method as Final.
  • PHP5 added several magic methods such as __call, __get, __set and __toString.
  • In PHP5 contains 3 levels of visibilities, Public, private and protected.
  • PHP5 introduced exceptions.
  • In PHP4, everything was passed by value, including objects. Whereas
  • PHP5, all objects are passed by reference.
  • PHP5 added interfaces with all methods defined in an interface must be public.
  • PHP5 included new error level defined as ‘E_STRICT’
  • PHP5 added new default extensions such as SimpleXML, DOM and XSL, PDO, and Hash.
  • PHP5 added new reserved keywords.
  • Additional OOP concepts have been added to PHP5 compared to PHP4.
  • PHP5 adds a reduced consumption of RAM.
  • Increased security against exploitation of vulnerabilities in PHP scripts.
  • MySQLi added for developers using MySQL 4.1 and later. Also bundled with PHP5 is SQLite.
  • PHP5 added the SOAP extension for interoperability with Web Services.
  • The SimpleXML extension has been added to PHP5. SimpleXML is used to access and manipulate XML as PHP objects.
  • Streams have improved inside PHP5 and now includes the ability to access low-level socket operations on streams.

Please beware that if you decide not to update your PHP5 and remain with PHP4, your website may not load correctly or appear down on the current generation of servers. 

Was this article helpful?

Yes (26)
No (6)

We're sorry you didn't find this article very helpful. Please help us improve it by leaving your feedback below.

Error