Rafe Colburn: I didn’t know until just now that you don’t need to include the closing ?> in PHP files that consist entirely of code. The Drupal coding standards explain why you probably want to leave it out:
Note that the final ?> should be omitted from all code files–modules, includes, etc. The closing delimiter is optional, and removing it helps prevent unwanted white space at the end of files which can cause problems elsewhere in the system.
News to me too. This may also be the cause of a rather common feed error. I’ve added the recommendation to the front of the solution section in the hopes that it helps somebody.
I find the recommendation as written to be confusing: it’s not clear that the ?> you’re referring to there is a PHP ?> and not the ?> from <?xml ... ?>, which is the only obvious antecedent on the page.
It can makes files look a bit unbalanced (like unmatched parenthesis, and can make you wonder if the file has been truncated. But it certainly has practical benefits.
PHP Tip 13 hours ago - Comment Huy Zing , Kevin Fox and Voyagerfan5761 liked this This is a good trick. I know for a fact that MediaWiki (one large PHP app) does this. - Voyagerfan5761 I did not know this, and have assiduously removed...
For all you many PHPers reading this, a little coding style tip (though I don’t know if we should just stick with WP style, whatever the heck that is)...