PHP dynamic object property is there a way to make it work? -
So I know that I can do something like this in PHP:
& lt ; Php $ X = 'A'; $ A = 5; Resonant $$ x;
what production will 5;
But it does not work with objects / properties. Is this code any way to work?
& lt ;? Php class FooBar {public $ foo; Public $ bar; Public function __ composition () {$ this- & gt; Foo = 'foo'; $ This- & gt; Bar = 'bar'; }} $ FooBar = new FooBar (); $ Str = 'Fubar- & gt; Foo '; Echo $ $ str;
It may be closed:
class FooBar {public $ foo; Public $ bar; Public function __ composition () {$ this- & gt; Foo = 'foo'; $ This- & gt; Bar = 'bar'; }} $ FooBar = new FooBar (); $ Str = 'Fubar- & gt; Foo '; List ($ square, $ attribute) = explosion ('- & gt;', $ str); Echo $$ class- & gt; {$ Attribute};
Comments
Post a Comment