Use of single quotes, double quotes, colons, and curly brackets in PHP

Source: Internet
Author: User

 
// Echo "<tr bgcolor = '{$ bgcolor}'>"; // echo '<tr bgcolor = "'. $ bgcolor. '">'; // echo" <tr bgcolor = \"". $ bgcolor. "\"> "; # echo" <tr bgcolor = "'. $ bgcolor. '">"; // wrong // echo' <tr bgcolor = '. $ bgcolor. '>'; # echo '<tr bgcolor =' $ bgcolor '>'; // wrong // echo "<tr bgcolor = '". $ bgcolor. "'>"; // echo "<tr bgcolor = ". $ bgcolor. "> ";
I will not elaborate on each statement, but I am puzzled when I encounter the first statement. The result leads to a series of equivalent statements. After trying for a while, I finally got started. In fact, it's just one or two tips. In PHP, strings can be output using single quotation marks and double quotation marks. However, in comparison, the former is slightly more efficient, but the two are different. Single quotes do not parse variables and escape characters, but double quotation marks both. As for the collocated character, the two strings are used. Two backslashes '\' in single quotes are equivalent to one. In double quotation marks, escape characters, colons, backslashes, and 'must be appended with' \ '. Use braces {} to separate the variables to be parsed from strings. Finally, the preceding six statements ensure the HTML <trbgcolor = "# fff"> or <trbgcolor = '# fff'> format.

Use of single quotes, double quotes, colons, and curly brackets in PHP

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.