I'm trying to create instances of a class but I'm having difficulties to have them have their own independent property values.
class A{
public static $value = NULL;
}
for ($i=0; $i <= 1; $i++) {
class_alias('A', 'A'.$i);
}
A0::$value = 1;
echo A0::$value; // echo 1
A1::$value = 9;
echo A1::$value; // echo 9
echo A0::$value; // echo 9
Here, A0::$value
should echo the value '1'.
I know they are alias so the only thing that changes is the name they are called by.
The class
I'm working on has lots of static methods
and properties
and I need to be able to call it like this A0::method()
from any part of the code so I can't just create instances of the class inside variables like this:
$A1 = new A();
$A2 = new A();
How can I create instances of a class where I can call it statically without the use of variables and have it with its own property values independent from other alias?