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:
Or you could access the properties dynamically:Code:// EXAMPLE 1 -- FLASH fido = new Animal (); fido.species = "dog"; fido.isHairy = true;
... which would have the same effect.Code:// EXAMPLE 2 -- FLASH fido = new Animal (); property1 = "species"; property2 = "isHairy"; fido [property1] = "dog"; fido [property2] = true;
Now the php counterpart to the first example would be this:
But what's the php equivalent to the second example? Is it even possible? Or maybe with some indirect method?Code:// EXAMPLE 1 -- PHP $fido = new Animal (); $fido->species = "dog"; $fido->isHairy = true;
Many thanks,
Jamie




Reply With Quote