When you send the header, this is just a consultation to the client (browser), who, in your opinion, should request a different URL. However, nothing can stop them from following your recommendation. They can continue to read more data from the current URL if your server continues to feed it. This is why you usually see php code that calls exit () after sending the redirect header, because if you stop issuing more data, they have nothing to read.
Besides the fact that they do not read unintentional data, there are other reasons:
It may just be pointless for the rest of the script to continue executing, wasting resources.
It is possible that runtime errors will occur if the script continues (for example, there were no variables or a connection to db could not be established).
It is possible that logical errors will occur if the script is continued (for example, the verification of user input / authentication has failed).
source share