note 34359 added to function.header

From: Date: Thu, 24 Jul 2003 19:27:25 +0000
Subject: note 34359 added to function.header
Groups: php.notes 
Request: Send a blank email to php-notes+get-52585@lists.php.net to get a copy of this message
If you omit the "exit;" call after each redirection header, they will essentially pile up, each execute, and you will be redirected to the location of the last one . I have noticed this common mistake among novice programmers. It is important to note that a header("Location:page") command does stop the rest of the page from processing. ** THE FOLLOWING CODE IS WRONG ** if ($x == 1) { header("Location: page1.php"); } header("Location:default.php"); ** SHOULD BE: ** if ($x == 1) { header("Location: page1.php"); exit; } header("Location:default.php"); exit; ---- Manual Page -- http://www.php.net/manual/en/function.header.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34359 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34359&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34359&report=yes

« previous php.notes (#52585) next »