This question already has an answer here:
- Why would one omit the close tag? 14 answers
In some scripts I see that they omit writing a closing tag ?>
for the script. Why is it and should I do this as well?
(I'm sure they have not forgotten it.)
This question already has an answer here:
In some scripts I see that they omit writing a closing tag ?>
for the script. Why is it and should I do this as well?
(I'm sure they have not forgotten it.)
Well, omitting the closing tag is just one solution for avoiding blanks and other characters at the end of file. For example any char which is accidentally added behind the closing tag would trigger an error when trying to modify header info later.
Removing the closing tag is kind of "good practice" referring to many coding guidelines.
php.net on PHP tags:
From PHP: Instruction Separation
They do it to avoid risking to have whitespaces after the closing tag which may stop headers to work.
This is, of course, true for PHP-only files.
CodeIgniter Framework suggests to omit closing tags for
You can read it here.