Solution to the difference between single quotation marks and double quotation marks
Source: Internet
Author: User
Difference between single quotes and double quotes textarea has two rows of data. name = sourceaaaaaaaaaaabbbbbbbbbbb I use explode (& quot; \ r \ n & quot;, $ _ POST ['source']) two elements use explode ('\ r \ n', $ _ POST ['source']) to have only one element. The difference between single quotation marks and double quotation marks
Textarea has two rows of data, name = source
Aaaaaaaaaaa
Bbbbbbbbbbbbb
I use explode ("\ r \ n", $ _ POST ['source']) to produce two elements.
Explode ('\ r \ n', $ _ POST ['source']) has only one element.
------ Solution --------------------
As for your location, the owner can tell you that it is in single quotes.
For example, $ src = explode (',', $ src );
------ Solution --------------------
$ Str = "hello ";
Echo '$ str'; // The result cannot be parsed: $ str
Echo "$ str"; // The parsed result is hello.
This is the difference between single quotes and double quotes.
I have not been dealing with php for a long time.
------ Solution --------------------
Php parses the variables in double quotes. for example, "$ I" is executed to display the value of the I variable.
However, if you put the '$ I' variable in single quotes, Php will directly output $ I, which is also displayed on the page without displaying the actual value of variable I.
------ Solution --------------------
Double quotation marks expand the variables, for example, $ varname = hello, "123 {$ varname} 123" is eventually "123hello123". double quotation marks escape the escape characters, for example, "\ n \ r" means a carriage return line break.
Variables are not expanded in single quotes. escape characters like escape are not allowed. except for single quotes, '\ n \ r' is the four characters.
------ Solution --------------------
Discussion
Php parses the variables in double quotes. for example, "$ I" is executed to display the value of the I variable.
However, if you put the '$ I' variable in single quotes, Php will directly output $ I, which is also displayed on the page without displaying the actual value of variable I.
------ Solution --------------------
Discussion
Textarea has two rows of data, name = source
Aaaaaaaaaaa
Bbbbbbbbbbbbb
I use explode ("\ r \ n", $ _ POST ['source']) to produce two elements.
Explode ('\ r \ n', $ _ POST ['source']) has only one element.
------ Solution --------------------
In the single quotation mark string, even the backslash also loses its extended meaning (except for inserting the backslash \ and the insert ticket
Quotation marks \'). Therefore, when you want to replace the variable in the string and include escape sequences such as \ n (linefeed), you should use double quotes
.
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.