Use php escape to output HTML to JavaScript and escape javascript. Use php escape to output HTML to JavaScript, escape javascript is a GIS integration recently. HTML to JavaScript should be output. it is troublesome to escape code. So HTML to JavaScript should be output using php escape, and javascript should be escaped.
Recently, Map World is integrated with GIS. HTML must be output to JavaScript. code escaping is troublesome. so, write a PHP function.
Share:
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;}
You don't need to use it. · call jsformat ($ str) directly)
The above is all the content of this article. I hope it will help you understand php escaping to javascript.
Please take a moment to share your article with your friends or leave a comment. Thank you for your support!
Recently, NLP is integrated with GIS to export HTML to JavaScript. it is troublesome to escape code. so...