Luke Luke - 7 months ago 25
PHP Question

Closing PHP tags after exit or die functions

Should I close PHP tags after

functions or it is not necessary?


According to the docs, only omit the closing tag if it's at the end of the file:

If a file is pure PHP code, it is preferable to omit the PHP closing tag at the end of the file. This prevents accidental whitespace or new lines being added after the PHP closing tag, which may cause unwanted effects because PHP will start output buffering when there is no intention from the programmer to send any output at that point in the script.


This applies to exit and die calls as well. They would run through the same parser as the rest of your php code.