enerjiza Posted October 11, 2007 Share Posted October 11, 2007 I'm still relatively new to OOP so I'm not sure if I'm doing this effeciently. Below are 2 examples of how I'm handling classes: class authors { private $db; private $articles; public function __construct($db) { $this->db = $db; $this->articles = new Articles(); } } Is there any other way I can call methods from the articles class without instantiating the articles class in the Authors class? I'm using PDO and passing the connection to the Authors class in the construct, is this the right way or is there a better way of handling this? Any input would be great. Quote Link to comment Share on other sites More sharing options...
SiriusB Posted October 11, 2007 Share Posted October 11, 2007 I am new to PHP, but I am familiar with OO Programming through Java and C#. There is nothing wrong with using classes inside other classes. It is a normal occurance. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.