// 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