Making use of Object Oriented PHP
This is a guest post by Tim, who has written on Jatecblog before. Tim runs Sacratee.
Since the release of object oriented programming in PHP, it has lead many people to write better and more efficient code, but still many programmers are unaware of this. I will show you a couple ways to make use of this not-so-new way of programming. Note, you must have PHP 5 to use the code below.
Modular System
With many new types of content management systems being created, it is no surprise people are making add-ons for them. This can be a pain if the CMS developer has not put in object oriented ways of streamlining the process of module development.
Below is some example code in which the user can easily add an item to a menu bar. First, the menu class the programmer of the application has implemented before hand:

myMod.php

As you can see, if makes the task much less tedious for the module developer.
Template System
Using PHP's OOP __ destruct method, we can easily have things run at the end of our script without specifically putting code there.

The above code would replace {name} with bob in template.html when outputted. Note, if you remove the reference to the class by overwriting $Template, that will call the __destruct method as well.
So there you go! A couple useful ways to use object oriented programming in PHP.

Daily Email Updates
You can get our how-to articles in your inbox each day for free. Just enter your name and email below:

Wow, this really cleared up a lot about OOP for me. Thanks a lot, waiting to see more.
[…] a quickie: From Tim of Sacratee there is a post on Jatecblog about Making use of Object Oriented PHP which provides a good simple example of how to use OOP in PHP5 to build a module-based […]
The article is nice, the code is ok, but I can't see the "why" of this article.
I agree that many PHP programmers are unaware of OOP in PHP, but I don't believe that this kind of article shows how to do it. The code is good, you show how to use the __construct, __destruct and __toString methods, although there is no explanation about them.
I guess this article should be named "How to create a menu bar using OOP in PHP" rather than "Making use of Object Oriented PHP".
Regards,