RE: [PHP] Escaping JavaScript strings

2008-05-29 Thread Edward Kay
> > This is a PHP function that escapes strings so you can output them as a > JS string. IIRC it assumes you're using single quotes to enclose your > strings. > > /** > * Function to appropriately escape a string so it can be output > * into javascript code. > * > * @p

Re: [PHP] Escaping JavaScript strings

2008-05-29 Thread Richard Heyes
> ... This is a PHP function that escapes strings so you can output them as a JS string. IIRC it assumes you're using single quotes to enclose your strings. /** * Function to appropriately escape a string so it can be output * into javascript code. * * @param string $stri

[PHP] Escaping JavaScript strings

2008-05-29 Thread Edward Kay
Hello, I'm adding functionality to allow a user to copy data on a page to the clipboard using JS. This can be done simply with: window.clipboardData.setData('Text','String to copy to clipboard'); The string from PHP needs to contain line breaks when copied into the clipboard. This works when I