I have to check, if a class has been initialized ( if I already done: $a = new MyClass; ). How can I do this using PHP?
Thanks.
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.
One way to do it is to let the class itself keep track of all its instances:
(Take care to decrease the count/references when destroying instances, yadayada…)
You may also just want to keep better track of your variables so you don’t have to figure it out later, that depends on what your goals are with this.