调用重定向函数头后,我是否应该调用exit?
<?php // fileA
$urlFailToGoTo = '/formerror.php';
if (sth)
{
header(sprintf("Location: %s", $urlFailToGoTo));
exit(); //should I call exit() here? or return?
}
?>
谢谢
调用重定向函数头后,我是否应该调用exit?
<?php // fileA
$urlFailToGoTo = '/formerror.php';
if (sth)
{
header(sprintf("Location: %s", $urlFailToGoTo));
exit(); //should I call exit() here? or return?
}
?>
谢谢
你绝对应该.否则脚本执行不会终止.仅设置另一个标头不足以重定向.