没有继续脚本php的重定向页面

时间:2014-09-30 13:45:20

标签: php html redirect header location

我必须检查表单中的信息,如果它是假的,我希望我的用户重定向而不继续脚本。它适用于header:location但脚本继续执行。

一个例子:

        foreach ($array as &$value) {
        if (empty($value)){
                header("location:garagecreation.php");

                }
    }
 ..... code code 

如果我的$值为空,我希望脚本停止并重定向。

感谢您花时间阅读本文。

2 个答案:

答案 0 :(得分:1)

您需要使用exit with header,就像这样

header("location: garagecreation.php");
exit;

答案 1 :(得分:1)

你必须使用:

header("location:garagecreation.php"); die();

相关问题