There are upcoming maintenance events which may impact our services. Learn more

PHP 4 to PHP 5 UPDATED Print

  • 1

PHP 4 AND 5 ARE NO LONGER SUPPORTED. BOTH VERSIONS ARE EOL AND DISCONTINUED

PHP 4 Upgrade To PHP 5 benefits


cPanel announces that EasyApache will no longer support PHP 4 beginning May, 2012. PHP 4 has not been actively developed, or supported by the PHP developers, for several years. Many CVEs reported against newer versions of PHP are also applicable in version 4, but remain unaddressed by the PHP developers. EasyApache will soon warn administrators that PHP 4 has reached End of Life when PHP 4 is selected. As early as EasyApache 3.12, PHP 4 will be removed from EasyApache. For an indeterminate period PHP 4 will be available as a Custom Option Module on http://easyapache.cpanel.net. This Custom Option Module is provided as a convenience for those who may need a longer period of time to transition away from PHP 4

Performance
PHP5 is faster than PHP4. The performance increase depends on a lot of factors, including the way an application is built, but in most cases, you will notice significant gains.
A key factor in the performance jump is the Zend Engine 2, the heart of the PHP language. Object handling has been almost completely rewritten to transform it from what was basically
a wrapper for associative arrays in PHP4 to a true object model. Object-oriented code in particular will perform faster in PHP5 as a result. Sebastian Bergmann, author of the PHPUnit test framework, bench-marked several PHP versions. The graph below summarizes his results.

Maintainability
There are several features in PHP 5 that improve the maintainability of applications. These include the new object model mentioned above which supports features such as abstract classes, interfaces, and encapsulation (private and protected methods and properties). This paper will not dive into the technical details of these features since other sources provide  excellent examples of the new functionality. The important thing to note is that these features make it easier to apply software architecture to a PHP application. In other words, it becomes  easier to write properly structured, high-quality code. The code base will be cleaner, easier to read, and consequently simpler to maintain.

Robustness
A new mechanism for error handling was added in PHP5. In PHP4, there was no dedicated mechanism for error handling at all. Programmers had to use regular language constructs such as if-statements to check for errors and use special return values to tell a calling method that something went wrong during the execution of a function. PHP5 also supports exception handling. Exception handling makes it possible to create
what is known as a try block to execute a piece of code that might contain an error and implement a catch that is called whenever something actually does go wrong. This makes it easier to separate the ‘what should happen in the case of an error’ code from the regular application business logic. This approach leads to cleaner applications, which in turn improves
developer productivity and application robustness.

Future-proof
The internet no longer consists solely of stand-alone applications. It is becoming more common for applications to interoperate, share data, integrate, and combine into ‘mash-ups’ to provide a richer internet experience. These kinds of applications allow you to read CNN’s headlines on your personalized Google homepage, display Flickr images of locations in other websites, and track packages in real time on a map of your home town. There are several technologies involved in these types of applications. Web services play a key role. A web service is basically an interface from one site to the other. When a site displays a UPS package in transit to a destination, it uses UPS’s web service to determine the coordinates and Google’s or Yahoo’s map service to display it on the map. Popular protocols for web services include SOAP and REST, two standards which make sure that websites can communicate with each other.

XML is another very important web app technology. XML is a data format for transferring data from one service to the other and consists of plain text messages that can be read by both computers and human beings, making it an ideal standard for interchanging data. The proliferation of these technologies is another reason to switch to PHP5. In PHP5, functionality was added to make it extremely easy to work with web services. If someone needs to connect to your application through a web service interface, you can create a web service for your application with just a few short lines of code in PHP5.

And the reverse, calling web services of other applications, can often be accomplished with as few as 2 lines of code. This paper doesn’t go into the technical details, but an internet search for ”PHP5 SOAP” should provide numerous examples. In PHP4, external libraries were necessary to properly implement web services. In PHP5, however, it‘s a feature of the language itself. Generating and parsing XML messages is also extremely simple in PHP5. In PHP4, working with XML was very cumbersome using the DOM or SAX parser. In PHP5, a new ‘SimpleXML’ extension has been added which makes PHP4 XML code look extremely complex by comparison. Using SimpleXML, an XML message can be read and parsed with a single
line of code.

Product support
There are more and more products available that take advantage of PHP5’s new features and add additional value to PHP5.

Zend Framework
The Zend Framework leverages PHP5’s new features to provide a rich set of classes that PHP developers can use to build applications. Examples include interfaces to many popular web services. The framework uses PHP5’s web services functionality to communicate seamlessly with web services and provide an easy-to-use interface for developers. This means that with PHP5 and the Zend Framework, you can talk to Amazon’s or Flickr’s web services without even knowing what a web service is.

Zend Core
Zend Core can be considered a PHP5 distribution. It includes Apache, MySQL and PHP itself, eliminating the hassle of having to compile or install these components manually. It also has an updater that ensures that you’ll always be using the latest stable, tested version of PHP and its extensions.

Open Source products
Many Open Source PHP projects are already taking advantage of PHP5‘s features. Increasingly,  these projects are recognizing the added value PHP5 provides and are considering dropping support for PHP4 altogether. Several projects have joined forces and launched the website http://gophp5.org, which features a list of applications that will fully adopt PHP 5.

Was this answer helpful?
Back