PHP DOC
The closing tag of a PHP block at the end of a file is optional, and in some cases omitting it is useful when using include or require, so unwanted white space will not appear at the end of the files, and you still will be able to add headers to the response after. It is also useful if you use output buffering, and you do not want to have a blank space added to the end of the parts generated by included files.
When you omit the closing tag ?>
it prevents white space or line breaks that may occur accidentally at the end of the file. For this reason many programmers choose not to close and you will find many frameworks that adopt this procedure.
If you omit closing and escape a character, you will get a syntax error: Parse error: syntax error .
If you close the ?>
tag and accidentally escape a character, you may get a: Warning: Can not modify header information , because there will be an output before the headers.