开发者

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

开发者 https://www.devze.com 2023-03-26 07:24 出处:网络
My code looks like this if (...) { if(check_if_already_done()) { header(\"location: home.php\"); }; do_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

精彩评论

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