> There is absolutely nothing in PHP which prevents you from implementing the
> singleton pattern.

It does if the constructor must be public.

> but your attempt is doomed to failure. What makes you think that a singleton
> class has to inherit from another class?

Nothing at all.  Except that in my particular case, I do need to
inherit from another class which has a public constructor.  And the
class I'm trying to write needs to be a singleton.

I guess that teaches me not to post a question without including a
doctoral thesis about what it is I'm trying to do.  I figured just
including the most base and/or basic parts of what I was dealing with
would be sufficient.  Though, I will say I probably shouldn't have
included all of that junk in the constructor in my OP.  That was just
a hail-mary-pray-it-might-be-a-workable-workround on my part.  I was
pretty sure it wouldn't be, but *shrug*

> Why can't it be a separate class,

In general, it can.  In my case, it can't.  Not unless I want to
completely duplicate an already existing class.

> or even a separate method in an existing class? If you use a static method
> then the activities of the constructor are irrelevant.

They aren't irrelevant if the class can be instantiated directly.
That sort of kind of breaks the whole singleton thing...

thnx,
Christoph

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

Reply via email to