I need to check if there exists an instance of class_A
,and if there does exist, get that instance.
How to do it in PHP?
As always, I think a simple example is best.
Now my problem has become:
$ins = new class_A();
How to store the instance in a static member variable of class_A
when instantiating?
It'll be better if the instance can be stored when calling __construct()
. Say, it should work without limitation on how it's instantiated.