4.0 isn't really an OO engine. It was a hacky addin to the existing 4.x procedural core. It is. . . not great to say the least, but for what they could do it turned out surprisingly well (no, I wouldn't use it either :P). 5.0 redefined the entire underlying engine for OO making it far more powerful. 4.x was more of a collection of functions and variables specific to a "group", or more close to a struct than an object.
Constructor name is often the name of the class. I haven't a clue why they redefined that in 5.x especially since the BC for 5 to 4 still dictates you can use them with the exception of namespaces matching the same classname for the ending portion of the namespace.
This is another great reason to not use PHP as your language of choice to learn OOP on.
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value.
Not even. Most of the time procedural will be less footprint and easier to perform the same task. One of the few exceptions is the privacy control which is quite complex to do in procedural. But you do take the tradeoff of re-usability, so you have to weigh which is more important to you.
OO is a good choice for a shared system that unknown individuals could add onto. This grants me control which is difficult to implement in procedural, and if implemented improperly can result in many bugs introduced by addon code that is difficult to debug.
OO was introduced in PHP3 though internally it was not true OO of any description just emulation of objects, Zend changed this and it grows with every version.
Lerdorf is not a gigantic fan of OO ala MVC etc
MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
Last edited by firepages; 11-22-2012 at 11:25 PM..
I think some of you guys have already said this with other words. But I think that when it comes to PHP and the choice of OO or Procedural you should really go with what you're most comfortable with. For example if you've for example been working a lot with C or any other procedural programming language you will probably find it more comfortable to keep using the same methods. And that's completely okay, because as many of you have already written there is not downside in performance when it comes to using procedural language. And according to me many well-commented procedural scripts are often easier to understand that mediocre OO-scripts.
Though if you're and hardcore Java programmer you might prefer the OO-way. And then that's definately the way to go as you will feel more comfortable with that. If you're a newbie; well then just go with what feels best for you. Try some OO-programming and see if you like it.
Personally I'm mainly working with procedural PHP code. Though I'm aware of some of the advantages of OO. And if I run into a problem which would be much easier to solve with OO programming, well then I'll do that.
Just don't feel like you have to choose a specific side in this ever lasting battle. Just follow your heart