I keep reading it is poor practice to use the PHP close tag ?>
at the end of the file. The header problem seems irrelevant in the following context (and this
It's pretty useful not to let the closing ?>
in.
The file stays valid to PHP (not a syntax error) and as @David Dorward said it allows to avoid having white space / break-line (anything that can send a header to the browser) after the ?>
.
For example,
header("Content-type: image/png");
$img = imagecreatetruecolor ( 10, 10);
imagepng ( $img);
?>
[space here]
[break line here]
won't be valid.
But
header("Content-type: image/png");
$img = imagecreatetruecolor ( 10, 10 );
imagepng ( $img );
will.
For once, you must be lazy to be secure.