About PHP closing tag “?>”

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.


The arguments in favor of omitting the tag look stronger (helps to avoid big headache with header() + it’s PHP/Zend “recommendation”). This isn’t the most “beautiful” solution in terms of syntax consistency, but I can’t find anything better.