- From: Gordon P. Hemsley <gphemsley@gmail.com>
- Date: Fri, 27 Aug 2010 15:02:58 -0400
On Fri, Aug 27, 2010 at 2:44 PM, Aryeh Gregor <Simetrical+w3c at 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 me at gphemsley.org http://gphemsley.org/ ? http://gphemsley.org/blog/ http://sasha.sourceforge.net/ ? http://www.yoursasha.com/
Received on Friday, 27 August 2010 12:02:58 UTC