PHP - Oophp Dialogue
Hi all.
I have some questions in reference to using OOPHP. All of my programming thus far has been procedural and that's worked out great for me, but there's (obviously) a huge market for OOP. I'm confused on how to apply the OOP concepts to what I'm already doing procedurally (or if OOP even applies to what I'm doing). A lot of what I do is PHP/MySQL, so how do I apply OOP concepts to that relationship? At what point do things become objects that should be put into a class? I found this example but it seems excessive compared to writing only a simple connection function http://forum.ragezone.com/f427/simple-oophp-mysql-connection-679020/ Similar TutorialsHi all. I'm starting a mini-project with the purpose of creating PHP generated charts. I just had a quick question on the class structure that I should use. My instinct tells me to do it like this: class chart{ function pie(){ } function bar(){ } } Is that a legitimate structure or is there a better way to do this? Hi all. I'm just getting my feet wet with OOPHP. My question is "why have a setter method when you can just use the __construct method to set everything?" and "would you need a separate setter method for each attribute of an object?"(i.e. set_first, set_last, set_gender, etc.) The code... <?php class person{ var $first; var $last; var $gender; function __construct($first,$last,$gender){ $this->first=$first; $this->last=$last; $this->gender=$gender; } function set_first($new_name){ $this->first=$new_name; } function get_person(){ return $this->first . $this->last . $this->gender; } } ?> |