jeffreyhi1 / loginsystem-rd

Automatically exported from code.google.com/p/loginsystem-rd
0 stars 0 forks source link

Closing PHP tags with trailing white space is a no-no. #64

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
In PHP, the tags to identify PHP code are ...

<?php
// PHP code.
?>

But if there is white space (new lines) following the ?> then these will be 
sent to the client as part of the request. This is an issue when the code has 
been included in a script and code following it has to deal with sending 
headers/cookies/etc.

By default, PHP is unbuffered, so everything is sent to the client as it is 
generated.

The white space tells the PHP interpreter that the headers (if any were sent) 
are all done and then to switch to body mode.

Then sending a header() or a setcookie() will trigger the error.

So, to stop this, it is common practise to remove the ?> from the end of 
include scripts.

Richard.

P.S. I'm not online the rest of the weekend ... can't deal with the code yet.

Original issue reported on code.google.com by RQuadling@gmail.com on 10 Jul 2010 at 11:43