PHP 4 and PHP 5
October 12, 2010 § 1 Comment
In most of the interviews I have been hearing the question “what is the difference between php 4 and 5”. Several time I heard the answer “actually the main difference is OOPS” . What does it mean …? OOPS was not there in PHP4 ..?
Thus I had a research on the features of php4 and php5 and found some interesting things that can be pointed out for a typical comparison between PHP4 and PHP5
The Object Oriented Concept was already there in PHP4. According to me a PHP developer one should identify the difference between the two versions by checking the phpinfo file as a first step. Then list all the things that was there in php4 and not in php5 and vice versa.
As a first step check the number of configuration items available in PHP4 and PHP5 the configuration values enormously increased in PHP5, i.e that much of new features and bug fixes.
As some quick note or as an important change we can pick default values of some configuration items
register_globals = Off in PHP5 and On in PHP4
magic_quotes_gpc = On in PHP5 and OFF in PHP4
safe_mode is deprecated in PHP5 and was there in PHP4
PHP5 includes a bundled library for Regular Expression
Advanced MySQLi support
Supports reverse engineering feature called Reflections ( That I will go in detail in my next blog )
SimpleXML extension ( bye to the typical DOM access on XML files ) provides a very simple and easily usable toolset to convert XML to an object that can be processed with normal property selectors and array iterators
Now coming to the code level where the developer dig for something.
Lots of features have been introduced. specifying all of them is not necessary and not at all important. Below I am mentioning some of the main features of PHP5 that we can use in code level.
magic functions ( __costructor, __set, __get, __toString etc ) google it for more details 🙂
supports access modifiers ( private, public, protected )
more advanced exception handling
pretty much organized garbage collection ( this has to be implemented using our own logic ) to see more read this