Please note this is not a duplicate. The seeming duplicates can all be answered by "Just save without a BOM already!" My question, however, is why?
If I save a PHP file inadvertently with a BOM, and I try to sent a header from inside the PHP, I get
Warning: Cannot modify header information - headers already sent by (output started at file.php:1) in file.php on line 1
You know the routine. And of course, it doesn't happen when the file is saved without a BOM.
However, and here's the tricky part: this warning does not occur everywhere! In my case, it doesn't occur when I open up the file from http://localhost/
, but it does occur when I upload the file to my website, and open it from there.
So, what's the difference? Is there a bug either my local Apache, or the website's Apache? Would the issue be solved by upgrading the buggy one to the latest version? Or could it be a configuration issue somewhere, that could be resolved by editing an ini file?