PHP中输出转义JavaScript代码的实现代码
分享一下:
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)
如对本文有疑问,
点击进行留言回复!!
相关文章:
-
-
-
-
-
-
-
-
-
-
视频爬虫
import os# 音视频处理import ffmpy3import requestsfrom bs4 imp...
[阅读全文]
-
网友评论