Difference Between PHP4 and PHP5

Posted by: WH13 Administrator on March 17, 2013 Under: Articles


What is PHP?

PHP is an open source scripting language. This language has been developed specially for web development so that dynamic web pages can be created. As it is one of the very first server-side scripting language that has been embedded in HTML, the users do not need any kind of external files to get access to the necessary data and information. PHP is a free tool. Whereas PHP stood for Personal Home Page in the beginning, later, its acronym has been changed to Hypertext Preprocessor.

This language was created in 1995 by Rasmus Lerdorf. However, now, it is implemented by PHP group.

Now that we have learned about what PHP is, let us have a look into the differences that are there between PHP4 and PHP versions.

PHP5 is different than PHP4 as its object oriented model is more improved and now it has become closer to ASP.NET.
Before, in PHP4, the class name and the constructor name were same. This used to create problem regarding overhead as all the occurrences had to be changed along with the class names. However, in the new PHP5, just naming the constructors and deconstructors does the job.
New interfaces have been introduced in PHP5. It helps the users to design APIs that are used often. These interfaces define the methods of a class. However, these methods have to be publicly declared/defined. A class can implement quite a number of interfaces even though only parent classes can be extended.
With PHP5, the users can now declare ‘ABSTRACT’ class as well. If the users use any kind of abstract method, they can declare that class as abstract.
Now, with PHP5, the users can also declare a method or class as ‘FINAL’. Just using the ‘FINAL’ keyword helps to make sure that a class will not be inherited or cannot be overridden by a method.

PHP4 vs PHP5
Picture 1 : PHP4 vs PHP5 based on Drupal 7 (Sources : buytaert.net)

In PHP5, there are quite a number of magic methods. These methods help to add assortment to the class functionality.
In PHP5, users have the ability to introduce ‘EXCEPTIONS’ as well. With this, exception error can be handled and the users can thus gain more control on the error notices of simple trigger.
Now, the users can take advantage of the visibility feature in PHP5. 3 Different Levels of visibility has been introduced. The most visible level is the ‘PUBLIC’ level. In this level, everyone can access the methods. Everyone has the abilities to read and rewrite the properties. Another level is the ‘PRIVATE’ level. In this level, class members are only visible in the class itself. The last is the ‘PROTECTED’ level in which class members are only accessible to the same class, the inherited class and the parent class.
A new error level named ‘E_STRICT’ has also been introduced in PHP5. This helps the users by notifying them when they are using any kind of depreciated PHP code.
In PHP5, new array functions such as array_combine, array_udiff, array_walk_recursive, array_unintersect etc. has been introduced.

Compare Hosting with both PHP4 / PHP5 Features included

HostGatoriPageIX Web Hosting

Top Rated Web Hosting

Rank Item Rating
1 A Host of Reviews About Hosting - Are the Bluehost Reviews True? Read
2 Hostmonster Reviews : The Hosting that Cares for Your Choice Read
3 Finding Stability in Motion—The Inmotion Web Hosting Review Read
4 Making Your Website a Cash Cow with FatCow Webhosting Read
5 GreenGeeks Reviews : World’s Top Rated Eco-Friendly Web Hosting Read

About WH13.com

We are a professional hosting review website, trying to help webmasters to find the hosting company that suit their needs and budget. WH13.com is independently owned and operated; reviews and guides are based thoroughly on personal experience.
Disclosure: We receive compensation from the web hosting companies, this does not influence the rankings and reviews on our website. We give high marks to companies that deserve it.

Search and Compare Web Hosting


Follow Us!