Dynamic properties with PHP classes
My question concerns referring to properties of php class instances dynamically. I know how to do it in Flash, so naturally I'm trying to find its counterpart in php.
In Flash, if you have a class called Animal which contains the properties species and isHairy, then you could do something like this:
Code:
// EXAMPLE 1 -- FLASH
fido = new Animal ();
fido.species = "dog";
fido.isHairy = true;
Or you could access the properties dynamically:
Code:
// EXAMPLE 2 -- FLASH
fido = new Animal ();
property1 = "species";
property2 = "isHairy";
fido [property1] = "dog";
fido [property2] = true;
... which would have the same effect.
Now the php counterpart to the first example would be this:
Code:
// EXAMPLE 1 -- PHP
$fido = new Animal ();
$fido->species = "dog";
$fido->isHairy = true;
But what's the php equivalent to the second example? Is it even possible? Or maybe with some indirect method?
Many thanks,
Jamie