源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

PHP中输出转义JavaScript代码的实现代码

  • 时间:2020-07-10 06:48 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:PHP中输出转义JavaScript代码的实现代码
分享一下:
[u]复制代码[/u] 代码如下:
function jsformat($str) { $str = trim($str); $str = str_replace('\\s\\s', '\\s', $str); $str = str_replace(chr(10), '', $str); $str = str_replace(chr(13), '', $str); $str = str_replace(' ', '', $str); $str = str_replace('\\', '\\\\', $str); $str = str_replace('"', '\\"', $str); $str = str_replace('\\\'', '\\\\\'', $str); $str = str_replace("'", "\'", $str); return $str; }
使用就不用说了,就是直接调用jsformat($str)
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部