Possible Duplicate:
Why do some scripts omit the closing PHP tag, '?>'?
I've seen in a PHP framework (I can't remember which) that they didn't close the php
tag (?>
) at the bottom of the pages.
Why is that and should I do it too?
If it's a PHP file that contains no HTML, then don't close the tag.
This stops you from accidentally adding whitespace at the end of the file, therefore invoking browser output, and by extension headers, etc, which can cause a world of pain.
The framework you saw is most probably Zend Framework. From the code style section of their manual:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With