Did you try to add it yourself?
The UTF-8 specification seems to be 0xEF 0xBB 0xBF , so you can attach it to your line after converting to UTF-8.
$utf8_with_bom = chr(239) . chr(187) . chr(191) . $utf8_string;
Beware. utf8_encode requires the string ISO-8859-1. If you are working with XML, make sure that XML is not yet encoded in UTF-8 encoding. Comments on the documentation indicate that the function is broken into many interesting ways, so you should not throw it if you do not know what you need.
Remember that PHP strings are just dumb, unknowable bytes. They have no binding to them, so if the data in the string is already UTF-8, you do not need to run the conversion.
In addition, a related Wikipedia article reads as follows:
While the Unicode standard allows specification in UTF-8 , it does not require or recommend it. Byte order does not make sense in UTF-8 , so the specification is intended only to identify a text stream or file as UTF-8 or that it was converted from another format that has a specification.
You probably don't need to worry about using the BOM bottle.
source share