In syntax-PHP, what does $ {} mean?

Source: Internet
Author: User
I have been using PHP for a short time. I know that $ username represents a variable, and in many cases it is written like this. Today, I suddenly saw the format & amp; quot ;$ {username} & amp; quot; in one place, and I couldn't understand it. What is this $ {} used for? It's been a short time in googl... using PHP. $usernameIs a variable, and in many cases it is written in this way.
Today, I suddenly saw "${username}"This way of writing won't be understood in an instant.
This ${ }What is it used to do? This stuff does not know how to search in google. It cannot be searched.

Reply content:

I have been using PHP for a short time.$usernameIs a variable, and in many cases it is written in this way.
Today, I suddenly saw"${username}"This way of writing won't be understood in an instant.
This${ }What is it used to do? This stuff does not know how to search in google. It cannot be searched.

Reference: http://php.net/manual/en/language.var...
To solve an ambiguous problem, it is used in places where ambiguity may occur and clearly tells the compiler how to interpret the code.

// DaiJie has more than one explanation in the Code. The php interpreter does not know what is correct. $ C = array ('D' => 'E'); echo "{$ c} ['D']"; // Array ['D'] $ c = array ('D' => 'E'); echo "$ {c ['D']}"; // e
// The null code is also ambiguous. $ var = "hello"; $ var _ = "world"; echo "{$ var }_$ var _"; // hello _ world $ var = "hello"; $ var _ = "world"; echo "{$ var _} $ var _"; // world

Prevents future Variables

                                         

Brackets in variable names are used to increase priority.

$ Title = 1;
$ {"Title_default _". $ title} = "selected ";
Echo $ title_default_1;
// Variable writing

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.