About PHP closing tag “?>”

Just my two cents about this debate. To summarize :

Always keep the closing PHP tag “?>” for files containing only PHP ?



  • Avoids headache with adding inadvertently whitespaces after the closing tag, because it breaks the header() function behavior… Some editors or FTP clients / servers are also known to change automatically the end of files (at least, it’s their default configuration)
  • PHP manual says closing tag is optional, and Zend even forbids it.


I would say that the arguments in favor of omitting the tag look stronger (helps to avoid big headache with header() + it’s PHP/Zend “recommendation”). I admit that this isn’t the most “beautiful” solution I’ve ever seen in terms of syntax consistency, but what could be better ?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s