In PHP, if I have a class with static member variables, such as:
class Foo
{
public static $a = 0;
public static $b = 1;
}
... and I have a string variable containing the name of the class:
$foo = 'Foo';
... how do I loop over the static data members of class Foo
using the variable $foo
?
Something like:
// Does not work
foreach ($foo AS $field => &$value) {
// Desired:
// Iteration 1: $field = 'a', $value = 0
// Iteration 2: $field = 'b', $value = 1
}
As noted, the above code snippet does not work.
Is this possible? If so, what is the syntax?
Thanks.