Duplicate:
What are the arguments IN FAVOR of PHP closing tags for PHP only files?
I have seen a lot of PHP scripts lately without the closing PHP tag ?>
I'm wondering if this is now the recommended method or if it's just people being lazy?
What are the arguments IN FAVOR of PHP closing tags for PHP only files?
I have seen a lot of PHP scripts lately without the closing PHP tag ?>
I'm wondering if this is now the recommended method or if it's just people being lazy?
It's to prevent accidental whitespace to be outputted to the browser.
If that happens header()
redirect methods will stop working if called after such an output.
The Zend programming guide has this to say:
For files that contain only PHP code, the closing tag ("?>") is never permitted. It is not required by PHP, and omitting it prevents the accidental injection of trailing white space into the response.
Personally? Open tags are meant to be closed.
You can find a great deal of discussion on this topic here.
But one of the major benefits that come from this is that your php files (the ones that contain just code) will never output whitespace which will cause problems if the whitespace is output and then you try to send the http headers again (ie start the session, etc).