website stat

OO vs Procedural Programming in PHP

I was browsing Zend’s website and I’ve discovered a nice article that describes one of the greatest things about PHP. I’m talking about procedural programming which avoids coding plenty of lines for doing one simple task. On the other hand this is also one of the greatest PHP drawbacks: sometimes we really need that OO programming for achieving complex tasks that need to be maintainable over time.

The article, Object Oriented vs Procedural Programming in PHP, it’s not new but I think it is worth mentioning. It tends a little bit for the PHP’s side but overall it serves the purpose. It gives some examples for each case.

Now what’s really missing is a truly OO in PHP. I’ll be looking forward to see this as soon as possible.


4 Responses to “OO vs Procedural Programming in PHP”

  1. David Ramalho
    Published at December 4th, 2005 at 5:21 pm

    Well, PHP > 5 has plenty of OO stuff (can’t really compare it with PHP 4), so much really that I don’t think you have to wait any longer :D , of course … no Namespaces yet, but hey, you can always name your 10000 classes package_subpackage_classname.class.php can’t you?? :( just kidding …. hopefully we can have that before PHP6 :)

  2. David Ramalho
    Published at December 4th, 2005 at 5:40 pm

    I couldn’t compare PHP 4 & PHP 5 because it would be pointless :) PHP 4 has basic (class { var, function }) stuff, and that’s it :)

  3. mlopes
    Published at December 4th, 2005 at 6:46 pm

    Well, PHP is getting better but it still lacks real OO. Scopes, anonymous classes, abstracts, interfaces, etc.. It getting better but I miss that stuff :-)

    On the other hand, it has one of the best procedural programming around that relieves the programmers’ life.

  4. David Ramalho
    Published at December 4th, 2005 at 7:29 pm

    Weeeeeeelllll , abstracts and interfaces you’ve got, Scopes no way (my complaint ;) ) , and on-the-fly classes I don’t think they exist, but you could jumble with Overloading (http://pt.php.net/manual/en/language.oop5.overloading.php) if you were so inclined :)

    refer to : http://pt.php.net/manual/en/language.oop5.php