Thursday, 13 June 2013

Difference between php4 and php5

PHP5 introduces many new features, I have mentioned some of them:

Unified Constructors and Destructors:
In PHP4, constructors had same name as the class name. In PHP5, you have to name your constructors as __construct() and destructors as __destruct().

Abstract:
In PHP5 you can declare a class as Abstract.

Startic Methods and properties:
Static methods and properties are also available. When you declare a class member as static, then you can access members using :: operator without creating an instance of class.

 _autoload()
PHP5 introduces a special function called __autoload()
Final:
PHP5 allows you to declare a class or method as Final

Magic Methods
PHP5 introduces a number of magic methods. __call, __get, __set and __toString

Visibility:
In PHP5, There are 3 levels of visibilities:
    Public: Methods are accessible to everyone including objects outside the classes.
    Private: only available to the class itself.
    Protected: accessible to the class itself and inherited class.

Exception:
PHP5 has introduced ‘exceptions’(exception errors)

Passed by reference
In PHP4, everything was passed by value, including objects. Whereas in PHP5, all objects are passed by reference.

Interfaces: 
PHP5 introduces interfaces . An interface defines the methods a class must implement. All the methods defined in an interface must be public.

E_STRICT Error Level
PHP5 introduces new error level defined as ‘E_STRICT’ E_STRICT will notify you when you use depreciated code.

PHP5 also introduces new default extensions.
SimpleXML: for easy processing of XML data
DOM and XSL 
PDO . 
Hash :gives you access to a ton of hash functions.

No comments:

Post a Comment