I don't understand a piece of code. please solve it. thank you.

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.