[ Team LiB ] Previous Section Next Section



This hour introduced some unfamiliar concepts. Do I really need to understand object-oriented programming to become a good PHP programmer?


The short answer is no. Most PHP scripts use little or no object-oriented code at all. The object-oriented approach won't help you do things that you couldn't otherwise achieve. The benefits of object-oriented programming lie in the organization of your scripts, their reusability, and their extensibility. The benefits of object-oriented design can be enormous, however, which is one reason why PHP 5 provides extended support for objects.

Even if you decide not to produce object-oriented code, you might need to decipher third-party programs that contain classes. This hour should help you understand such code.


I'm confused by the special variable $this.


Within a class, you sometimes need to call the class's methods or access its properties. By combining the $this variable and the -> operator, you can do both. The $this variable is the handle a class is automatically given to refer to itself and to its components.

    [ Team LiB ] Previous Section Next Section