Re: singleton in php?
| From: | robert janeczek | Date: | Wed, 04 Sep 2002 20:58:18 +0000 |
| Subject: | Re: singleton in php? | ||
| References: | 1 | Groups: | php.lang |
| Request: | Send a blank email to php-lang+get-377@lists.php.net to get a copy of this message | ||
> i want it so i only ever have one object of this class ever in my program.
> all new instances of the object will simple be references to the first
> object.
>
> how can i implement this? i can do it in java by making the constructor
> private and then having a static method to return a static variable init
to
> an object of the class if it is not init yet.
>
> how can i have a singleton object in php?
> ASAP via email as well. cheers
you should look at some pear classes code. for example - log class provides
method to create single instances.
rashid