NogDog;10880140 wrote:I see no reason you cannot do it. Just be aware that the static variable in the parent class can be modified by any instantiation of that class or any other child classes that extend it, so that part of the singleton class will not exactly be "singleton" in its nature.
Which is pretty much what I want, or rather what I was pondering on.
In a class hierarchy, can some of the descendent branches terminate in a singleton?
kakki;10880141 wrote:i guess, that $instance is static, therefore all attributes of myParent are static as well ...
Should be, at least in the singleton instantiation. I was just making sure. I may find that I need or want it to be otherwise though.
What I am thinking on here is a static pdo class that gets it's db vars ($var2) from a parent class that reads a system config file ($input1) from a path outside doc root. Just security: don't leave the db password lying around where people can get at it. The same file reader would also pass system settings (more $var2) to other child class constructors.
I was just wondering if anyone had come across such a pattern before and knew the ins and outs of using it.