The header() function is used to send original HTTP header information, such as redirecting, setting cookies, modifying content types, etc. However, HTTP header information must be sent before any actual output (such as HTML, echo, print, etc.) or an error will be thrown. This is because once the output starts, PHP will automatically send the HTTP header.
header