Which one works best?
Are you a newbie in the PHP language? If you are, for sure you have encountered two kinds of PHP approaches programmers use nowadays: the procedural and the object oriented (OO). Different experienced programmers have already used both approaches, and most probably they would recommend only one kind of PHP approach to you. There are some who would say that it’s best to stick with the traditional procedural, while others would say that OO is much better to use. It can be quite confusing as to which approach to follow, but in order to make a choice, you must first know the pros and cons of using procedural and OO PHP.
For novice programmers, procedural PHP is probably the first PHP practice you will be exposed to. It’s because it’s the approach almost every programmer knows how to use, and its traditional tenets have already been established and easy to learn. Most web pages operate in a procedural manner, i.e. this tag, then this tag, then this tag, and so on. Using procedural PHP code with HTML is rather straightforward unlike OO, and programmers are given more space and freedom to create their own styles using the procedural approach.
Procedural PHP works heavily on the performance behind the code, thus programmers tend to come up with codes only they can understand. This is one of the major disadvantages of procedural PHP; in the effort to make things faster and more efficient, you create codes that cannot be used by anyone else, unless they get to figure what the codes are. Procedural PHP is also quite difficult to maintain, extend and distribute, unlike OO.
On the other hand, object oriented PHP or OO, are more inclined to work on the front lines of the programming world. In OO, you do not really have to think about the performance behind your creation, since you’re doing it for the sake of eye candy. Moreover, OO PHP is easier to distribute and maintain, since its main goal is to be placed anywhere and everywhere in the web. If you plan more on taking a career on web design and documentation, then OO PHP is for you.
OO also showcases productivity. Unlike the repetitive process of procedural PHP, you can actually skip this process due the creation of class files are more organized and reusable. Thus, you do save time and have more space to customize the codes you have created. OO PHP works best when you have to use complex functions in your project, when you plan to use the same code in future projects, as well as when you can’t run certain functions more than once on a page without logical errors.
You can find a lot of skins, and other fancy designs that operate behind OO PHP, mainly because the said approach focuses more on the look and feel of the object, rather than its performance. Packages such as Smarty and FPDF use object oriented PHP, so if you’re about to use these programs, then OO is the approach you should follow.
Meanwhile, for fast-working programmers who divulge more on the functionality and performance of the codes, then procedural programming is the one for them. You can actually find them using programs such as osCommerce and phpMyAdmin.
Choosing between procedural and object oriented PHP depends on your needs and tasks as a programmer. If your work inclines you to do more on performance, effectiveness and functionality of codes when it comes to programming, then procedural programming could cater to your needs. If you on the other hand would want to explore more on the abstract and creative side of programming, then you may as well work on object oriented programming.

This post is not very well founded.
As a PHP programmer since PHP3, I have ten years’ commercial experience with the language, as well as fluent perl and good exposure to four or five other languages. Back in PHP3, there was no OO, and so that’s what I started with.
Having since had experience with both models, plus both models in perl, and modern OO languages such as Ruby, I believe I am reasonably informed.
I believe that it is often said that OO code is somehow more ‘structured’ or ‘re-usable’ than procedural code, and that this is simply incorrect.
Good PHP procedural code is just as powerful as OO code.
It is very easy for OO programmers to pretend they are producing quality code, whereas in fact they are programming an infectious monster that does not offer any or many opportunities for elegant re-use outside of the initial problem domain. This is the case a large percentage of the time with most OO PHP programmers.
For this reason I always emphasise the use of procedural code for overall logic. Object oriented approaches are only used on specific problem domains that are both well defined and well suited to the OO model.
Posted by walter | 04. Aug, 2009, 8:07 amThanks for both this article and also the response made to it by Walter.
Im new to PHP, just starting, and for the last few weeks ive been reading and trying some basic things out.
I have been very confused mainly because of trying to understand the procedural approach while at the same time trying to take in the OOP approach too and its simply doing me no good trying to learn it this way.
After reading what has been posted here im going to get my head into learning the procedural way, and i think it will relieve me of some of the confusion that ive recently experienced.
I was starting to get frustrated and someone on a forum was even trying to talk me into the OOP way, i thought learning OOP PHP was what i simply had to do, like its a must but i realise now that its not.
Procedural PHP here i come.
Posted by John | 25. Jun, 2010, 6:23 amI agree with walter.
There are so many OO programmers that writes OO codes but they don’t understand the principle of OO Design Pattern. Some just write codes the OO way without any design pattern, so that the execution performance it self is so slow.
Quote : Object oriented approaches are only used on specific problem domains that are both well defined and well suited to the OO model. >> This is where design pattern apply i think.
CMIIW
Posted by Didit | 06. Jul, 2010, 8:48 pm