"1" single and double quotation marks when dealing with variables:
Variables enclosed in double quotation marks will interpret the values, but they are not processed in single quotes and are output directly;
"2" If you want to escape in the statement, then you must use double quotation marks.
For example, when you go to define single quotes, write this:
The program will show He\ 's name is Tom intact, if this is written:
The program will show: He's name is Tom.
====================================================
The meanings of write escape characters are listed below (they have special meanings when using these characters in double quotation marks)
| < span="">
| < span="">
| < span="">
| < span="">
| < span="">
| < span="">
| < span="">
| < span="">
| < span="">
| < span="">
| < span="">
| < span="">
| < span="">
| < span="">
| < span="">
| < span="">
====================================================
Here's an example to illustrate the difference between using single and double quotes:
Quotes
Use double quotes: "; echo"$quantity \$ $price \$ $total.
\ n "//print result using single quote: Echo 'Use single quotation marks:
'; Echo '$quantity \$ $price \$ $total.
\ n ';? >
The final results are as follows:
================================================================
================================================================
1. This example prints the result in double quotation marks, and is another solution to the single-quote print result of an example in this article (the number of entry variables for PHP).
2, in this case, because the double quotation marks are able to print out the variable, so we put everything to print in double quotes, but the only problem is to print the $ symbol problem, to print out the $ symbol, we can directly escape.
3. What is the difference between using a newline character (\ n) in both quotes???
A: When a newline character (\ n) is placed in double quotation marks, it creates a new line in the HTML source code. When placed in single quotation marks, it will print out \ and n directly.
================================================================
FAQ:
1, in the operational efficiency of single quotation marks and double quotation marks are also different, in general, single quotation marks run faster, double quotation marks will be slower, because the double quotation marks to find whether there are variables in the statement, and single quotation marks are not used, so if there is no substitute variable in the statement as far as possible single quotation marks. This is a habit of writing programs, always thinking about improving the efficiency of the program.
2. When using PHP to print HTML, it is easiest to use single quotes.
echo '
If you want to print out this HTML code in double quotation marks, you will have to escape all double quotes in the string.
echo "
3, if you still don't know the difference between these two quotes, you can use double quotation marks, which is unlikely to be a problem.
http://www.bkjia.com/phpjc/743820.html www.bkjia.com true http://www.bkjia.com/phpjc/743820.html techarticle "1" single and double quotation marks when dealing with variables: variables enclosed in double quotation marks will interpret values, but are not processed in single quotes, direct output;? php$var = ' My ...