gmdavisUX
gmdavisUX

Reputation: 192

NOT typical PHP headers warning

I have seen headers warnings before due to HTML or a space or in the file before sending headers. I know to avoid that. I have a file that generates an XML file and I can successfully set the content-type as XML when I run it on my localhost. When I run it on my production server, I get the "headers already sent" warning.

My suspicion is that something on the server is running before the file (even though I address the file directly, not as an include). I suspected WordPress so, to hopefully avoid this, I created a subdomain and placed the file there to no avail.

How can I detect if something is loading before the file on the server? Does WordPress take over the whole domain, subdomains and all? If so, is there a way to prevent this? I want this to run outside of WordPress.

Upvotes: 0

Views: 36

Answers (2)

symcbean
symcbean

Reputation: 48357

If you're sure that there's no prepended characters in your script (you have checked for a BOM marker?) then the most likely cause is the webserver is configured to auto-prepend a file - you can verify this by:

print ini_get('auto_append_file');

Upvotes: 0

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324620

You may have an auto_prepend_file directive in your php.ini, but I think it's most likely that you are falling prey to the BOM at the start of your file. You should ensure that your files are being saved as UTF-8 without BOM (sometimes referred to as "ANSI as UTF-8"), and ensure that the server is keeping this encoding too.

Upvotes: 1

Related Questions