Today I learnt: it’s considered best practice to not close <?php
tag with corresponding ?>
at End-of-File!
– Did you know it?
Looking at WordPress sources I noticed (specially it was clearly seen for “silence is golden” files) that there’s no closing php-tag. I was curious enough to go to online sources which they still have in SVN (I went to Github first, but links were kinda broken so I started studying it from https://core.trac.wordpress.org/ ) and found huge developers conversation (or arguing may be more precise to say) in regards of this subject.
It turned out then that official PHP manual explicitly states it:
Note: 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.
</?php not>