headers already sent - works in local but not on the host!?
Posted: Wed Oct 08, 2008 5:37 am
I tried redirecting a page with header() and all I got was that dreadful "header already sent by".
I tried using ob_start() and similar... but with no luck.
Then I just created one php file:
I tried that file at my localhost apache server and it worked and redirected, but when I uploaded it to my webhost server - the warning message appeared again!
What on earth was already sent, when the ONLY command was the header itself??
Then I erased the line above and added this code only
Surprisingly, that command produced strange results:
when used on my localhost:
array(1) { [0]=> string(23) "X-Powered-By: PHP/5.2.6" }
but on webhost:
array(2) { [0]=> string(23) "X-Powered-By: PHP/5.2.6" [1]=> string(23) "Content-type: text/html" }
Why and who added the "content-type"!? What's going on?
I tried using ob_start() and similar... but with no luck.
Then I just created one php file:
Code: Select all
<?php header ('location: http://somelocation.com'); ?>What on earth was already sent, when the ONLY command was the header itself??
Then I erased the line above and added this code only
Code: Select all
var_dump(headers_list());when used on my localhost:
array(1) { [0]=> string(23) "X-Powered-By: PHP/5.2.6" }
but on webhost:
array(2) { [0]=> string(23) "X-Powered-By: PHP/5.2.6" [1]=> string(23) "Content-type: text/html" }
Why and who added the "content-type"!? What's going on?