我在使用 PHP
header location
时感到困惑。哪种方式是最佳实践...?
if(true){
header("location:somepage.php");
}
或
if(true){
header("location:somepage.php");
exit;
}
最佳答案
发送 `Location:' header 后,PHP 将继续解析,并且 header() 调用下面的所有代码仍将被执行。所以改用你的第二个例子:
if(true){
header("location:somepage.php");
exit;
}
关于PHP这是header定位的最佳实践,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23993207/