[Javascript] String on multiple lines

Scott Reynen scott at randomchaos.com
Mon Jun 19 18:42:01 CDT 2006


On Jun 19, 2006, at 6:28 PM, Paul Novitski wrote:

> Oops, I meant:
>
>         var variable = "<?php echo str_replace("\\n", "\\\\n",  
> $variable); ?>";
>
> Any case in which you're referring to the backslash character, and  
> not its effect on the subsequent character, it needs to be escaped  
> with a second backslash.

I think you had it right the first time.  If I'm understanding the  
original question, he doesn't actually have the character "\"  
followed by "n" in $variable.  He has a line break, not a backslash,  
and a line break in PHP is "\n".  The character "\" followed by  
"n" (the replacement) is "\\n" or more simply '\n' (single quoted  
strings aren't parsed).

Peace,
Scott




More information about the Javascript mailing list