Closed (fixed)
Project:
Documentation
Component:
Correction/Clarification
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
9 Jun 2008 at 20:15 UTC
Updated:
24 Jan 2009 at 20:40 UTC
I think it would be helpful to have some information on the coding standards page regarding the usage of single/double quotes.
Comments
Comment #1
david straussI support single quotes for everything except:
(1) In-line variable usage (which I discourage).
(2) Translated strings where one can avoid escaping single quotes by enclosing the string in double quotes. One such string would be "He's a good person." It would be 'He\'s a good person.' with single quotes. AFAIK, such escaping isn't handled properly by .pot file generators.
Single quote strings are known to be faster because the parser doesn't have to look for in-line variables.
Comment #2
john morahan commentedIs there a standard for database queries? Queries with embedded single quotes are apparently always double-quoted strings, but other queries seem to use both quote styles. For example, contrast filter_admin_delete_submit with profile_field_delete_submit.
Comment #3
heather commentedChanged the component to reflect the new component categorization. See http://drupal.org/node/301443
Comment #4
emmajane commentedThe page http://drupal.org/coding-standards has been updated to include information on 'quoting' standards. It was reviewed by Heine before it was added. Two paragraphs were added. The first is from http://pear.php.net/manual/en/standards.bestpractices.php and the second is a variation on the text from David Strauss (as written above).