我不确定哪些字符需要在字符串中转义。我的PHP代码给出了字符串参数,但有时它有引号和双引号,我不知道该怎么做。
onclick="eventBox('This is the string ' // " "')"
答案 0 :(得分:3)
引号("
)应替换为"
。反斜杠(\
)前置于'
。
onclick="eventBox('This is the string \' // " "')"
答案 1 :(得分:1)
您需要转义引号或对其进行编码,以便正确解析。
onclick="eventBox('This is the string \' // " "')"
否则会因错误匹配引号而导致解析错误