3raser Posted March 28, 2012 Share Posted March 28, 2012 (example I looked at: http://develturk.com/tags/selfinstance/) I've looked into the singleton pattern and a few examples. I've understood most of its concept, but I still have a few things puzzling me. I noticed that you're not supposed to allow cloning (obviously) or the construction method as it shows in an example: //this object can not copy //except the getInstance() method. private function __clone() {} //prevent directly access //we want acces this only from getInstance method. private function __construct(){} Do I also have to do this for child classes, or just the parent class? Link to comment https://forums.phpfreaks.com/topic/259849-singleton-pattern/ Share on other sites More sharing options...
trq Posted March 28, 2012 Share Posted March 28, 2012 Child classes inherit all parent's properties and methods. Link to comment https://forums.phpfreaks.com/topic/259849-singleton-pattern/#findComment-1331768 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.