Quotes-How to accurately understand PHP,. "' $val '". This notation

Source: Internet
Author: User

Although I will be this way, but has not been how to understand the principle of writing, in PHP because of the special meaning of single and double quotation marks, so I see a lot of quotes will have a nod, especially this kind of several quotation marks nested in the same way not how to understand, the friend to help explain the meaning of writing so, I just know that in IDE tools this variable will change color ....

Reply content:

Although I will be this way, but has not been how to understand the principle of writing, in PHP because of the special meaning of single and double quotation marks, so I see a lot of quotes will have a nod, especially this kind of several quotation marks nested in the same way not how to understand, the friend to help explain the meaning of writing so, I just know that in IDE tools this variable will change color ....

In PHP, the single quotation marks will be the default string, the double quotation mark Zend Engine will determine whether there will be variables exist, if there are variables, will parse the variable.

So here, actually does not need to use the connector to write, can write directly,

echo "连接符";

The usage upstairs is correct, I will explain your usage. In PHP "." is used to connect strings, so you can put the "." Before and after splitting into two parts, so that your code is actually "string" + variable + "string", where the double quotation marks are used as wrapping strings. Next is the use of the A tag, and the URL after the property href= should be quoted as you should know, because double quotation marks can no longer appear in double quotes, so the use of single quotation marks instead. Don't you know I'm clear?

PHP distinguishes between single and double quotation marks, double quotes can have single quotation marks, and single quotes can also have double quotation marks.

When parsing, strings using single quotes do not automatically replace variables inside, and strings that use double quotes replace variables and function calls inside, so double quotes are a bit slower than single quotes.

Official document (String): Http://php.net/manual/zh/language.types.string.php#language.types.string.syntax.single

  • 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.