note 109087 added to function.header
| From: | sedativchunk at gmail dot com | Date: | Tue, 19 Jun 2012 19:17:10 +0000 |
| Subject: | note 109087 added to function.header | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-188705@lists.php.net to get a copy of this message | ||
I already see the PHP documentation contains this but I wanted to leave a note to let people know
how important it is. ALWAYS use the exit command after a PHP header redirect!
<?php
header ("Location: index.php");
// Make sure you exit your code
exit;
?>
Alot of examples on the web fail to follow the statement with the exit command. I was contracted to
do a huge social networking site several years ago and left the exit statement out of the code. This
led to huge leaks in security and also caused a PHP headers already sent message. It caused me a
major headache and I didn't realize what was doing it at the time. Now I use it in all my jobs.
That's the thing with PHP, no one really teaches it formally so you have to make mistakes with
it to learn things like this. It's in the PHP documentation but it's something I
completely missed. Maybe this will be a nice heads up for someone looking on using the header
function.
----
Server IP: 69.147.83.197
Probable Submitter: 24.131.27.37
----
Manual Page -- http://www.php.net/manual/en/function.header.php
Edit -- https://master.php.net/note/edit/109087
Del: integrated -- https://master.php.net/note/delete/109087/integrated
Del: useless -- https://master.php.net/note/delete/109087/useless
Del: bad code -- https://master.php.net/note/delete/109087/bad+code
Del: spam -- https://master.php.net/note/delete/109087/spam
Del: non-english -- https://master.php.net/note/delete/109087/non-english
Del: in docs -- https://master.php.net/note/delete/109087/in+docs
Del: other reasons-- https://master.php.net/note/delete/109087
Reject -- https://master.php.net/note/reject/109087
Search -- https://master.php.net/manage/user-notes.php