php - Should I call exit() after calling Location: header?

后端 未结 5 1202
情书的邮戳
情书的邮戳 2020-11-22 03:38

After calling the redirect function header, should I call exit or not?



        
5条回答
  •  粉色の甜心
    2020-11-22 04:18

    exit is bad coding.

    if you ever develop a big project and want to create PHP Unit Testcases, exit will screw you up.

    exit terminates the script and your running test! there is no way to recover the test and tell if it has failed or not ...

    organise your code the way, that there is no output and the script ends naturally if you use a redirect ...

提交回复
热议问题