I have a little struggle with this, and I will be very pleased to help.
In a PHP variable, variables can easily be defined as follows:
$a = "myVar";
$$a = "some Text";
print $myVar;
Now, how do I do this in an OOP environment? I tried this:
$a = "myVar";
$myObject->$a = "some Text";
print $myObject->myVar;
I also tried $myObject->{$a} = "some Text", but it does not work either. Therefore, I must be wrong somewhere.
Thanks for any help!
source
share