Re: Singletons

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



""Christoph Boget"" <jcboget@xxxxxxxxx> wrote in message 
news:540509760810201224h4eb54e03p65bf583ff312f14d@xxxxxxxxxxxxxxxxx
>
<snip>
>
>> Singletons are not rocket science, but as with all patterns you really 
>> need
>> to understand the theory before trying to implement and use it.
>
> Agreed.  But apparently implementing them in PHP leaves things to be 
> desired.

There is absolutely nothing in PHP which prevents you from implementing the 
singleton pattern. There are several ways in which it can be done (take a 
look at http://www.tonymarston.net/php-mysql/singleton.html for an example) 
but your attempt is doomed to failure. What makes you think that a singleton 
class has to inherit from another class? Why can't it be a separate class, 
or even a separate method in an existing class? If you use a static method 
then the activities of the constructor are irrelevant.

-- 
Tony Marston
http://www.tonymarston.net
http://www.radicore.org 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux