On Fri, Aug 27, 2010 at 2:44 PM, Aryeh Gregor <simetrical+...@gmail.com> wrote: > > PHP offers no JS-string-literal-escape function. `addslashes` is very close, > > but won't handle some cases with non-ASCII characters correctly. Better to > > use `json_encode` to transfer the string, then write as text: > > > > elmt.textContent = <?php echo json_encode('Hi there, '+$name, > > JSON_HEX_TAG); ?> > > > > (assuming innerText or Text Node backup for IE/older browsers.) > > Interesting, that's useful. Too bad it only works in PHP 5.2 or higher.
PHP 5.2.0 came out in 2006. I don't see anything "too bad" about using PHP 5.2 or higher with new technology.[1] Regards, Gordon [1] See also: http://gophp5.org/ -- Gordon P. Hemsley m...@gphemsley.org http://gphemsley.org/ • http://gphemsley.org/blog/ http://sasha.sourceforge.net/ • http://www.yoursasha.com/