[Javascript] String on multiple lines

Scott Reynen scott at randomchaos.com
Mon Jun 19 20:58:18 CDT 2006


On Jun 19, 2006, at 7:19 PM, Paul Novitski wrote:

> But, "single quoted strings aren't parsed"?  I'm not familiar with  
> such a rule in either PHP or JavaScript.  I thought single & double  
> quotes were interchangeable in both languages.  Please elucidate.

I think they're interchangeable in JavaScript (I'm not entirely sure  
- that's why I'm here), but not in PHP:

http://www.php.net/manual/en/ 
language.types.string.php#language.types.string.syntax.single

Only \' and \\ are parsed in single quotes, so you can put quotes  
within your quotes.  Everything else is treated as the exact  
characters within the quotes.  This has the advantage of slightly  
faster execution.  In PHP, you can put variables within double-quoted  
strings, like "My name is $name" so parsing strings is a bit slower  
than JavaScript.  Variable interpolation is handy for writing code  
quickly, but for writing quick code, you can use single quotes and  
the PHP runtime won't waste time looking for variables and other  
escaped characters to parse.  Running mostly client-side and without  
variable interpolation (I think), JavaScript strings don't have as  
much reason for unparsed single quoted strings.

Peace,
Scott



More information about the Javascript mailing list