How to escape string from PHP for javascript?
问题 lets imagine a form editor, it can edit available values. If the data contains " character (double quote) it "destroys" HTML code. I meant, lets check the code: so I generate HTML: onclick="var a = prompt('New value: ', '<?php echo addslashes($rec[$i]); ?>'); if (a != null).... and it results in onclick="var a = prompt('New value: ', 'aaaa\"aaa'); if (a != null) { v.... and this makes JS work impossible, so that it ruins the code. With single qoute ' it works OK. mysql real escape does the