开发者

Why php skips header(location:...) if no die; after it

My code looks like this

if (...) {

   if(check_if_already_done()) {
      header("location: home.php");
   };


   do_it();
   header("location: done.php);

}

in this case even if already done returns true its going to done.php instead of home.php but when i add die; after header("location: home.php"); it does go to home.php can someone explain why? It has to do with finishing main IF before doing header even if that header is at the end of n开发者_Go百科ested if?


even after the first header() is called php keeps processing, so it reaches the 2nd header call a few millsecounds after the first and runs it.

and the location should be an absolute url.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜