OOP vs Functions and includes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, This is my first post. English is my 2nd language so I apologize for any mistakes I might have.

I would describe myself as an intermediate self-thaught PHP programmer, which means I can do lots of stuff but probly my coding techniques sucks :P

Anyway, Im reading a lot about OOP lately, and I've fixing other's people scripts which use OOP for "small" stuff that could have been acomplished with simple functions or includes maybe... so I started wondering, why use OOP when you can use something simpler...

Imagine the following example:
A table of MySQL on a simple classifieds site holds the info for each Ad posted ( timestamp, user who posted it, title, description, location, country, etc).
A php page called ads.php gets the ad ID via $_GET and prints out its information in a nicely formated page.


What I usually do is to put all the "echo-ing" part of this page in a separate include (ie: ads_details.php ), so that if I need to also show this in another page, I call the same include. If I decide to do a change later, I only have to change it in one part of the script alone.

What I've seen a lot lately is that people do the same with classes (they write a class that will output the same thing I output thru an include)... so I guess there must be pros and cons regarding using both methods...

Could anyone point me to a good reading (free, internet) material to read about this or any other advice so I continue learning about OOP and when to use it ?

If you read it all the way down here THANKS !  :D

Pablo Fernandez-Stearns
BA. Argentina.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux