Will PHP script be executed after header redirect?

前端 未结 10 2084
天涯浪人
天涯浪人 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:55

    Yes, the script continues to process after the call to header('Location: http://google.com') if you don't explicitly terminate it! I just tried this locally. I added test.php to a site in apache with these contents:

    
    

    And checked my /var/log/apache2/error_log for this entry:

    [Tue Feb 12 23:39:23 2013] [error] [client 127.0.0.1] WE MADE IT HERE SOMEHOW
    

    Possibly surprising, but yes, it continues to execute if you don't halt execution.

提交回复
热议问题