可能重複:
php - Should I call exit() after calling Location: header?退出()和不在頭部函數之間有什麼區別?
我不知道如何標題這個問題,但在這裏不言而喻。
就是下面的兩個代碼段之間的區別:
SCRIPT1 - 無exit()
:
if($var = true){
header('Location: anotherpage.php');
}
SCRIPT2 - 與exit()
:
if($var = true){
header('Location: anotherpage.php');
exit();
}
從我個人理解,header()
退出當前頁面,並跳轉到另一頁,如果條件爲真,因此具有exit()
之後header()
毫無意義 - 我說得對嗎?
總是用出口 – 2012-12-02 07:14:56
@Dagon你介意解釋更加爲什麼呢?謝謝 – anagnam
看到我貼的愚蠢 – 2012-12-02 07:16:42