Will PHP script be executed after header redirect?

前端 未结 10 2059
天涯浪人
天涯浪人 2020-12-03 13:41

Yes, this question has been asked before, however, the answers have been inconsistent. Take Why I have to call 'exit' after redirection through header('Location

10条回答
  •  庸人自扰
    2020-12-03 13:49

    header("Location: http://example.com/newURL.php");
    die;
    

    Yes the script continues after the header redirect, so make sure to call die; or exit; any time you you redirect to stop execution. Don't need to put the script to sleep :).

    How to make a redirect in PHP?

提交回复
热议问题