Quotation marks considered harmful

From: Date: Thu, 04 May 2006 18:53:02 +0000
Subject: Quotation marks considered harmful
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-235553@lists.php.net to get a copy of this message
John Wells wrote:
Personally, I get tired (and confused) when having to escape all of those quotes like in the string you're trying to echo above. Perhaps you'd consider HEREDOC as an alternative approach:
Here's n idea I've had and never expressed publicly before. I wonder if some of you haven't thought the same thing: Why not develop a language syntax that has distinct open and close string delimiters? So (in an ideal world) the code in question echo " <td width=\"25%\" align=\"center\"> <a href=\"javascript:open_window('$php_self?action=view_record&userid=$userid');\"> view</a> <a href=\"$php_self?action=delete_record&userid=$userid\" onclick=\"return confirm('are you sure?');\">delete</a></td> "; would be rendered something like this: echo { <td width={25%} align={center}> <a href={javascript:open_window({$php_self?action=view_record&userid=$userid});}> view</a> <a href={$php_self?action=delete_record&userid=$userid} onclick={return confirm({are you sure?});}>delete</a></td> }; or like this: echo [ <td width=[25%] align=[center]> <a href=[javascript:open_window([$php_self?action=view_record&userid=$userid]);]> view</a> <a href=[$php_self?action=delete_record&userid=$userid] onclick=[return confirm([are you sure?]);]>delete</a></td> ]; Of course, having separate characters for opening and closing double or single quotes would work, but that would require changing the basic ASCII set. I believe some European languages use "<<" and ">>" as quotation marks. What ASCII characters do they use? I have seen some JavaScript code that uses curly braces to delimit a string, but can't find that documented anywhere. Thoughts anyone? --J

« previous php.general (#235553) next »