The punctuation in programming language is not as we speak can be casually add others also know what you want to say, but the computer is not the same, the use of improper will cause errors will cause you very annoying, PHP single and double quotation marks are frequently encountered by novice users of the problem, this article explains the difference between the two, I hope to help the novice!
In PHP, typically a string is defined in a pair of quotation marks, such as:
' I am a string in single quotes '
"I am a string in double quotes"
The PHP parser uses pairs of quotes to determine a string. Therefore, all strings must use the same single or double
Quotation marks to define the start and end. For example, the following string definitions are not valid:
"I am not a valid string since I had unmatching quote marks '
' Me neither! '
When defining a string, only one quotation mark is considered a definition, that is, single or double quotation marks. So if a string is represented by a double-cited
Number, then only double quotes are parsed by the parser. In this way, you can include any other character in a double-quote string, or even a single-cited
No. The following string of quotes is valid: www.2cto.com
$s = "I am a" single Q This example attempts to include double quotes in a double-quote string, whereas the parser considers the string knot when it encounters the second double quotation mark
A bundle. To achieve the purpose of containing quotation marks, the parser must ignore the literal quotes in the string, and we
Preceded by a backslash to tell PHP: This quotation mark is part of the string, the correct way to represent it:
"Why doesn ' t \" that\ "work?"
A common problem in English strings is the use of apostrophes because it is a single quotation mark, which is very common in English strings.
(All in English). You must handle these characters with care:
' You\ ' d better escape your a post rophes '
You can see that the backslash has his special meaning in the string, and when we need to include the backslash itself in the string, we need to
The symbol is preceded by a backslash. For example:
$file = "C: \ Windows \system.ini";
Echo $file; Printing results: C:windows System.ini
$file = "C:\\windows\\system.ini";
Echo $file; Printing Result: C:\Windows\System.ini
Uote string ' inside a double quote string ';
$s = ' I am a ' double quote string ' inside a single quote string ';
Author: Fei Yu 1993
http://www.bkjia.com/PHPjc/478103.html www.bkjia.com true http://www.bkjia.com/PHPjc/478103.html techarticle punctuation in programming languages is not the same as we speak can be casually add others also know what you want to say, but the computer is not the same, improper use will cause errors will cause you ...