Possible Duplicate:
Why do some scripts omit the closing php tag '?>'?
I’ve been reading some articles about Omitting Closing PHP tags since they say it is a good programming practice in PHP if your .php file doens’t contain any other things. There are many questions like that but after I tried what they’ve done so far worked well on my machine. Maybe it is a fixed issue or something?
But I don’t quite understand why it could be a good programming practice since it brings space or something but I’ve tried this one and works very well.
Master.php
<?php
echo "Master.php";
include "Slave.php";
header("Location:Slave.php");
?>
Slave.php
<?php
echo "Slave.php";
?>
I don’t really quite get what the problem should be if I didn’t use closing php tag.
Thanks.
The main issue is you may include additional whitespace (but it can be any chars) after the closing
?>(besides one\nwhich PHP allows, thanks Mario).This extra whitespace appears to PHP as output to be sent. This makes PHP start sending the response body, therefore making any additional headers being set/modified impossible.
This is hard to debug (as whitespace is generally invisible in text editors) and often the cause of the dreaded Headers already sent error.