Problems with nested single quotes and double quotes
自律者自由
自律者自由 2017-10-24 23:35:26
0
3
2188

First sentence: var str = "My name is'" name "'"

Second sentence: var str = "My name is\"" name "\""

You said that only double quotes can be nested within single quotes, and only single quotes can be nested within double quotes. I can understand the first sentence, but I can't understand the second sentence because it is full of double quotes.

自律者自由
自律者自由

reply all(3)
nearest

\ is an escape character, and the symbols following it become entity output, and there are no quotation marks here.

豆豆

"My name is\"", in fact, I want to output: My name is"

and then connect the name,

"\"", this output is",

The final output is: My name is "name",

\ is the escape character, if there is no \ in "\"", the syntax is wrong, and with \, has become escaped, you can output the "


immediately following \
路过

\ This is called an escape character, which means that the symbol behind it is directly output

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!