Chapter 1
[ 15 ]
Difference of OOP in PHP4 and PHP5
Objects in PHP5 differ a lot from objects in PHP4. OOP became matured enough in
true sense from PHP5. OOP was introduced since PHP3 but that was just an illusion
for real object oriented programming. In PHP4 you can create objects but you can't
feel the real flavour of an object there. In PHP4 it was almost a poor object model.
One of the main differences of OOP in PHP4 is that everything is open; no
restrictions about the usage of methods or properties. You can't use public, private,
and protected modifiers for your methods. In PHP4 developers usually declare
private methods with a double underscore. But it doesn't mean that declaring a
method in that format actually prevents you from accessing that method outside the
class. It's just a discipline followed.
In PHP4 you can find interfaces but no abstract or final keyword. An interface is a
piece of code that any object can implement and that means the object must have all
the methods declared in the interface. It strictly checks that you must implement all
the functions in it. In the interface you can only declare the name and the access type
of any method.
Pages:
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32