I'm having trouble suppressing the PHP location header from the output buffer. I understand that output buffers must suppress headers until they are discarded. I also thought that no headers should be sent with ob_end_clean ().
However, if you see the code below, if I uncomment the header line (second line), I always redirect to google and never see "finished".
ob_start();
//header("Location: http://www.google.com");
$output = ob_get_contents();
ob_end_clean();
$headers_sent = headers_sent();
$headers_list = headers_list();
var_dump($headers_sent);
var_dump($headers_list);
die('finished');
I need to suppress any header redirects, ideally catch them in the output buffer, so I know that these conditions will lead to a redirect. I know that I can do this with curl (setting up forwarding to false), but since all the files I want to buffer are on my own server, curl is very slow and binds the loads of db connections.
Does anyone have any suggestions or any ways to catch / suppress location headers?
Thanks Tom
source
share