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

后端 未结 6 1219
清酒与你
清酒与你 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:07

    Output is generally not sent (depending on output buffering and so on) if you redirect like that, but as shown by the unlink() example the script does not die with header().

    So the exit() or die() calls are necessary if you want to prevent the script from continuing after the redirect.

提交回复
热议问题