简体   繁体   中英

how to use single quote inside double quote while double quote already inside single quote?

我有字符串$html = ' <button onclick="js_func(this, "in this point")"> submit </button>'我想将字符串发送给我正在尝试使用'/'' string '\\' js函数'/'' string '\\'也带有"/"" string "\\"但尚未得到解决方案。请为我提供正确的解决方案。

只需使用反斜杠将其转义,就像这样简单:

$html = ' <button onclick="js_func(this, \'in this point\')"> submit </button>'

With \\ ==> ' < button onclick="js_func(this, \\"in this point\\")"> submit < /button>'


Escape quotes in JavaScript

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM