joebeeson http://blog.joebeeson.com programming, knick-knacks, minutiae posterous.com Tue, 30 Mar 2010 20:08:16 -0700 Stop closing your PHP files http://blog.joebeeson.com/stop-closing-your-php-files http://blog.joebeeson.com/stop-closing-your-php-files There are 4,030,000 links on Google for "headers already sent by output started" that's four million, thirty thousand pages referencing a problem that is entirely avoidable -- ending your PHP files with a "?>"
The closing tag of a PHP block at the end of a file is optional, and in some cases omitting it is helpful when using include() or require(), so unwanted whitespace will not occur at the end of files, and you will still be able to add headers to the response later. It is also handy if you use output buffering, and would not like to see added unwanted whitespace at the end of the parts generated by the included files.
It is such an annoying issue that many frameworks and libraries have adopted a "no closing tag" policy for their own coding standards... So, in closing there is absolutely no reason to put a closing tag in your source code so knock it off already, okay?

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1305637/42a9ad8d2315a7c6384163af80299a65.jpeg http://posterous.com/users/36p0W9fBRbsB Joe Beeson joebeeson Joe Beeson