i have to list objects that are instance of a class by refrence
class Foo {}
class Foo1 {}
$obj1 = new Foo;
$obj2 = new Foo;
$obj32 = new Foo1;
i need a solution to get all objects that are instance of Foo class
do you know how to do that ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A solution to get all instances of a class is to keep records of instantiated classes when you create them:
Now the globally accessible array
Foo::$instanceswill contain all instances of that class. Your question was a bit broad so I can not exactly say if this is what you’re looking for. If not, it hopefully helps to make it more clear what you’re looking for.