3 ms·
Uhm, no... http://php.net/manual/en/language.oop5.patterns.php http://php.net/manual/en/language.oop5.patterns.php A singleton uses a static factory method in
by gabordemooij 15y ago
Uhm, no...
http://php.net/manual/en/language.oop5.patterns.php http://php.net/manual/en/language.oop5.patterns.php
A singleton uses a static factory method in PHP and Java. AFAIK there is no (mainstream) language where a singleton is an instance method.
- stephenr 15y agoNo, a singleton still has a constructor though - it's just not public. It's called when the factory method creates a new instance. the factory static method is NOT the constructor.
- gabordemooij 15y agoYes this is correct. The constructor in a singleton pattern is private. I meant the way to obtain an instance is the same. Sorry for my mistake.