Pages

Saturday, September 14, 2013

OOPS-PHP4,PHP5-difference

1. In PHP4 there are no access modifiers everything is open we can't use public,private or protected for our methods.

2. In PHP4 there are interfaces but no abstract or final keyword.

An interface can be implemented by any object and which means that all the functions of interface must be implemented by the object.We can only declare the name and access type of any method in an interface.

An abstract class is where some methods may have some body too.

A final class cannot be extended.

3. In PHP4 there is no multiple inheritances for interfaces but Php5 supports multiple inheritance via implementing multiple interfaces together.

4. In PHP4 everything is static i.e if we declare any method in class which uses $this keyword we can call the same via classname::method() i.e. without instantiating the class which is not allowed in PHP5.

5. There is no class based constant,static property,destructor in PHP 4.

6. PHP 4 allows shallow copy of object.But in PHP 5 shallow copy is possible only via clone keyword.

7. PHP 4 does not have an exception object where as PHP 5 has an exception object.

8. Method over loading via magic functions like __get() and __set() is possible in PHP 5

No comments:

Post a Comment