Posted by -Lost on 04/27/07 14:48
ashore 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.
I imagine we would generate content that JavaScript could handle.
<script type="text/javascript">
var blah = '<?php print 'a\\nb\\nc'; ?>';
</script>
For example.
--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
[Back to original message]
|