[wp-hackers] Discussion about Optional Closing PHP tags in the WordPress Library

Otto otto at ottodestruct.com
Wed Jun 18 14:02:18 GMT 2008

On Tue, Jun 17, 2008 at 7:23 PM, Jacob Santos <wordpress at santosj.name> wrote:
> Right, so the problem is this. If you leave the closing PHP tag out, then
> you have people informing you that you have a bug since PHP "requires" a
> closing PHP tag.

As has probably been pointed out, this is incorrect. PHP does not
require the closing tag, and it is in fact recommended practice to
leave off the closing tag when the file ends with a block of PHP code.

This is the recommended coding standard for virtually all PHP projects
out there, WordPress being the notable exception.

> Really, from the commonly quoted message on the subject, the conclusion
> translates to that it is better to have the closing PHP tag, so that those
> who don't know better don't get tripped up on the small stuff. Whether or
> not WordPress should have the closing PHP tag is not at issue here. How is
> this problem, when it occurs troubleshooted for users?

No, actually the correct conclusion is that it is better to omit the
closing tag in all cases where it is not needed. And, in fact, I
recommend people remove it from wp-config on a regular basis.

This is, in fact, a huge and often repeated problem that occurs
regularly on the support forums. So much so that we have made several
statements in the codex about it. Search the forums for "Cannot modify
header information - headers already sent". This is almost always
caused by a blank line somewhere.. And 80% of the time it's in the
wp-config.php file.

Also, people create the wp-config.php file manually, because the
installation instructions tell them to do so. They don't let WordPress
create it for them, even though it can. In fact, I pointed out to
somebody the other day that it was capable of doing this, and they
were amazed. People who have used WP for years have no idea that it
could create your wp-config file for you.

Just something to keep in mind. And I recommend that we remove the
closing ?> from *all* files that end with it.


More information about the wp-hackers mailing list