I don't understand a piece of code. I want to solve it. thank you for not understanding it. thank you.
The following code
Class foo {
Var $ bar = 'I am bar .';
}
$ Foo = new foo ();
$ Bar = 'bar ';
$ Baz = array ('foo', 'bar', 'Baz', 'quux ');
Echo "{$ foo-> $ bar} \ n ";
Echo "{$ foo-> $ baz [1]} \ n ";
?>
Output result:
I am bar. I am bar.
Question 1: \ n line breaks have been used in the program. why is there no line breaks in the output result, but a line
Question 2: {$ foo-> $ bar} refers to the bar variable in the foo class.
{$ Foo-> $ baz [1]} does not understand this section. why is I am bar output? the class foo does not contain baz.
Thank you!
Reply to discussion (solution)
$bar = "test\n";echo $foo->$bar;?>
','
';abc::$i=3;echo abc::out();
1. \ n is a text line feed.
Html line feed
2. because the value of $ baz [1] is bar ($ baz = array ('foo', 'bar', 'Baz', 'quux ');)
In fact, you don't understand $ foo-> $ bar. it just happens that the bar of $ bar has the same name as the bar of the class attribute.
Figuring out the variables is the true meaning
Are you there? $ Bar? Value? Required? Such
$ Foo-> bar = "?? ";
bar = "test\n";echo $foo->bar;
Thank you for understanding.