The solution to get all instances of a class is to keep records of the instance classes when they are created:
class Foo { static $instances=array(); public function __construct() { Foo::$instances[] = $this; } }
Now the globally accessible array Foo::$instances will contain all instances of this class. Your question was a little broad, so I canβt say for sure whether this is really what you are looking for. If not, it will hopefully help make it clearer what you are looking for.
hakre source share