/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* // example usage <script type="text/javascript"> var str = '<?= to_js_string($html) ?>'; </script> */ function to_js_string($str) { return str_replace(array("\\", "'", "\r", "\n"), array('\\\\', "\'", ' ', ' '), $str); }