Yes, this question has been asked before, however, the answers have been inconsistent. Take Why I have to call 'exit' after redirection through header('Location
Running the code:
//http://www.php.net/manual/en/function.header.php
header('Location: http://google.com');
flush();
sleep(3);
$a=fopen('test.txt', 'w');
fwrite($a,headers_sent());
fclose($a);
The server paused and wrote the file before the client redirected me. This is because, even after flush()
ing the buffer, the the redirect is not processed until the script ceases execution (ie, the script terminated). The file test.txt
had '1' in every case, meaning that the headers were sent, just not processed by the browser until the connection was terminated.