Variable variables in OOP

Saosinner

New Member
Hi everyoneI'm having a little struggle on this one and would appreciate some help.In PHP variable variables can easily be defined like this\[code\]$a = "myVar";$$a = "some Text";print $myVar; //you get "some Text"\[/code\]Now, how do I do that in a OOP enviroment? I tried this:\[code\]$a = "myVar";$myObject->$a = "some Text"; //I must be doing something wrong hereprint $myObject->myVar; //because this is not working as expected\[/code\]I also tried \[code\]$myObject->{$a} = "some Text"\[/code\] but it's not working either. So I must be very mistaken somewhere.Thanks for any help!
 
Back
Top