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. Link to comment https://forums.phpfreaks.com/topic/72839-including-objects-within-another-object/ 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. Link to comment https://forums.phpfreaks.com/topic/72839-including-objects-within-another-object/#findComment-367379 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.