Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我不确定我的字符串中需要转义哪些字符。我的 PHP 代码给出了字符串参数,但有时它有引号和双引号,我不知道该怎么处理。
onclick="eventBox('This is the string ' // " "')"
引号 ( ") 应替换为". 反斜杠 ( \) 附加到'.
"
"
\
'
onclick="eventBox('This is the string \' // " "')"
您将需要转义引号或对其进行编码,以便正确解析。
否则会因为引号不匹配而导致解析错误