ARCHIVE: PHP Code tags
Last modified: January 16, 2009 - 13:51
Note: This information is included in the Coding Standards page
Always use <?php to delimit PHP code, not the <? shorthand. This is not just a Drupal coding standard, but is also the best way to ensure your code is portable across differing operating systems and PHP configurations.
Note that as of Drupal 4.7, the ?> at the end of code files (modules, includes, etc.) is purposely omitted. The full discussion that led to this decision is available from the no ?> needed at the end of modules discussion on the drupal-devel mailing list, but can be summarized as:
- Removing it eliminates the possibility for unwanted whitespace at the end of files which can cause "header already sent" errors, XHTML/XML validation issues, and other problems.
- The closing delimiter at the end of a file is optional.
- PHP.net itself removes the closing delimiter from the end of its files (example: prepend.inc), so this can be seen as a "best practice."
