PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I've tried out this Singleton pattern for a few objects and it helps me with dealing with references versus copies that may occur (from not paying attention). However, I have an object (user login object) that I save to the session, and would like to retrieve. I created a SetInstance() function in order to allow this is be transportable, but I've run into a problem with the __CLASS__ magic constant.
instanceof accepts 'string' (T_STRING), $var, $obj->property and alike (dynamic_class_name_reference) on the right side. But not __CLASS__ (T_CLASS_C). If you pass a variable of the type string it uses the value as a classname.