PHP header() gets sent after ouput

joanwhite

New Member
Until recently, my LAMP was working as I expected and using PHP's header() to redirect behaved according to documentation. Out of nowhere, this changed. The problem can be seen here:\[code\]<html><head><title> BLAH </title></head><body><p> TEXT </p><?php echo "BLAH BLAH BLAH"; sleep(10); header("Location: http://example.com");?></body></html>\[/code\]As far as I know, the redirect should not occur - but it does. I tried echoing, adding HTML, waiting to avoid any possible race conditions, all to no avail. When I access this page, no output is shown, and after 10 seconds I get redirected.I wasn't very lucky searching the web as most people have exactly the opposite problem, nor did I find anything useful in the server logs. I haven't done any configuration changes or package updates. The people I asked were also puzzled.I'm running PHP 5 and Apache 2 on a CentOS virtual machine.P.S.: My first question here, but reading this site has helped me many times and I just love it :) .
 
Back
Top