Use PHP escape to output HTML to JavaScript, escape JavaScript
Recently in making a day map is GIS integration • • To output HTML to JavaScript inside • • What's the trouble with code escaping? · So write a PHP function.
Share:
function Jsformat ($str) { $str = trim ($STR); $str = Str_replace (' \\s\\s ', ' \\s ', $str); $STR = Str_replace (CHR), ', $str); $STR = Str_replace (CHR), ", $str); $str = Str_replace (' , ', ', $str); $str = str_replace (' \ \ ', ' \\\\ ', $str); $str = Str_replace (' "', ' \ \" ', $str); $str = Str_replace (' \\\ ', ' \\\\\ ', $str); $str = Str_replace ("'", "\ '", $str); return $STR;}
The use of it is needless to say • is to call Jsformat directly ($STR)
The above is the whole content of this article, I hope you can understand that PHP escaped to JavaScript helpful
Please take a moment to share the article with your friends or leave a comment. We would be grateful for your support!
http://www.bkjia.com/PHPjc/974663.html www.bkjia.com true http://www.bkjia.com/PHPjc/974663.html techarticle use PHP escape to output HTML to JavaScript, escape JavaScript recently in making a day map is GIS integration • • To output HTML to JavaScript inside • • What's the trouble with code escaping? · So ...