|
Posted by Peter Michaux on 04/27/07 14:40
On Apr 27, 7:35 am, ashore <3ash...@comcast.net> wrote:
> Say I'm using a snippet like
> $phpfoo = "a\nb\nc";
> var jsfoo = "<?php echo $phpfoo;?>";
>
> This errors out because JS sees the newline, and it needs to be
> escaped somehow. (In my real case, $phpfoo came from MySQL, and it's
> retrieved and displayed OK.)
>
> What do you folks use in this kind of situation? Thanks, all.
If the $phpfoo string in PHP contains a new line then this is
something you solve with PHP before you print it into the HTML page.
Turn the new line character into somthing that will print as "\n" into
the page if you want the JavaScript to see the new line.
Peter
[Back to original message]
|