JavaScript有没有像PHP中的
例如,将此字符串:
``` This is a demo string with 'single-quotes' and "double-quotes". ```
转换为:
``` This is a demo string with \'single-quotes\' and \"double-quotes\". ```
addslashes
(或addcslashes
)这样的内置函数,用于向需要转义的字符添加反斜杠?例如,将此字符串:
``` This is a demo string with 'single-quotes' and "double-quotes". ```
转换为:
``` This is a demo string with \'single-quotes\' and \"double-quotes\". ```
system
需要做出各种反应的唯一方法是使用其他函数,该函数允许您传递未转义的参数。 - Jo Liss