views:

87

answers:

4

I have quite a strange problem with PHP and Apache on my local testing server. For some reason it keeps stopping sending headers to the browser (I am pretty sure that is the problem anyway).

It's not a case of the old 'output already sent' as it was working fine, had the problem, went away after I reinstalled Apache and is now back again. Sessions also appear to be broken. It also gives no errors for 'headers already sent', plus the code works on the live site.

It's not the browser either as I tried different browsers and different machines, which exhibit the same problems.

Even something dumb such as <?php header ('Location: http://www.yahoo.com'); ?> doesn't work.

I am running wampserver (latest version) on Windows. Answers on a postcard.

+1  A: 

Even something dumb such as <?php header ('Location: http://www.yahoo.com'); ?> doesn't work.

Try with this instead:

<?php header('Location: http://www.yahoo.com'); exit; ?>
troelskn
A: 

Firstly, check that your PHP.INI has 'display_errors' set to 'On' and while you're at it, make sure 'error_reporting' is set to 'E_ALL & ~E_NOTICE'. Without those, you won't see errors even if they occur.

Secondly, ensure that you set 'output_buffering' to 'Off' in the same file. Just in case.

Finally, there was mention of checking your Apache log. It's also important to check your PHP error log (which is generally a different file again).

Narcissus
I've got full warnings (and notices) on and there is no alert.
Meep3D
Do you have display_errors on, too? It has to be explicitly set to actually see those errors, no matter what you've set to show. Also, have you checked the PHP error log as opposed to the Apache one?
Narcissus
+1  A: 

A reinstall fixed it, bizarrely enough.

Meep3D
+1  A: 

Are you using Xdebug? It has a known issue with headers.

Álvaro G. Vicario
Yes. Maybe that was the problem. I've since nuked that install so I can't check but I'll try removing Xdebug if it happens again to see it that fixes it.
Meep3D