BOM in php script output

I am providing a web service on a dreamhost server and the client is receiving what looks like a byte order mark in the content body of the script output as follows.


The relevant lines of script code follow.

$msg = ‘’;

global $msg,$errors; //inside validation function

global $msg; //inside db insert function

global $msg; //inside key generate function

$msg .= ‘key=’.functionThatReturnsString(); //inside key generation function

global $msg;
header(‘Content-type: text/html’);
header('Content-Length: ’ . strlen(utf8_decode($msg)));
echo $msg;

There cannot be a BOM before the header(string) calls or I would be getting a PHP warning, no? I am not getting any warnings.

Does echo(string) insert a BOM (or other hidden characters) before the string argument?

Can someone tell me how those characters are getting inserted into the content body?

I am clueless. Thanks for your attention.

Could be trouble with the editor used to save the script.

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost

Well, twas not the almighty that lifted her nighty…um…er…rather, the BOM was coming from an included script file. Once the BOM was removed from the included file, the response was correct and things are working correctly now.

Perhaps a note of interest to anyone reading this post, I incorrectly assumed that the BOM could not come from somewhere prior to the header() function calls, and that the script would return PHP warnings about headers already sent if the problem preceded those calls. Apparently not.