do I need to use exit after header(“Location: http://localhost/…”);?

后端 未结 6 1235
清酒与你
清酒与你 2021-02-19 02:53

I\'m creating a script to validate a form and I was asking myself a question. When I use a header (see example below), do I need to use exit right after? I mean, does using head

6条回答
  •  星月不相逢
    2021-02-19 03:28

    I use exit after the header->location call because I want to be able to rely ABSOLUTELY on the fact that the script won't get past the header->location call.

    If there's a bug somewhere and your script starts generating output BEFORE the header->location call, the call will fail, and script execution will continue normally (unless you call exit)

提交回复
热议问题