How PHP variable variables work? -
I know how PHP variable variables work, but there is a problem understanding why this script is "I am r . " Instead of "I'm B"
& lt ;? Php square fu {var $ bar = 'I'm the bar.'; Var $ arr = Array ('I am', 'I am b', 'I am'); Var $ r = 'I am' '; } $ Fooo = new Fuo (); $ Arr = 'arr'; $ Fooo- & gt; Resonate $ arr [1] "\ N"; // top line output // i am r? & Gt;
You are defining $ arr = 'arr'; and then getting the second letter from string 'arr', not array in class Foo, this is the reason why you 'r' ( [1] is returning from your word to second letter is). Solution? You should replace: $ fooo-> $ Arr [1] echo "\ N"; With :
echo $ fooo-> Arr [1] "\ N"; You should get your desired output:
'I am'
Comments
Post a Comment