Closing PHP tag considered harmful

php — Tags: , , , , — Glen @ 2:28 pm

A good tip from Zend, who recommend omitting the closing PHP tag (?>) when your files contain pure PHP code. This can prevent additional whitespace being inserted into the script output. Extra whitespace can cause problems, for example, if you are trying to set your own custom HTTP headers: nothing should be output before the call to the header function. Otherwise, this classic error will occur:

Cannot modify header information - headers already sent by (output started at myinclude.php:16) in myscript.php on line 15

Zend Framework: Documentation

  • Share/Save/Bookmark

0 Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2009 Glen Scott - Keeping it simple | powered by WordPress with Barecity