website/errors/whitespace.bom.md
A PHP file that starts with a UTF-8 Byte Order Mark (BOM) character (EF BB BF in hex):
<?php declare(strict_types = 1);
echo 'Hello';
The BOM is an invisible character at the very beginning of the file, before the <?php opening tag.
The file begins with a UTF-8 BOM (Byte Order Mark) character. While the BOM is valid UTF-8, it causes problems in PHP files:
header(), session_start(), and other functions that must be called before any output.Remove the BOM character from the beginning of the file. Most code editors have an option to save files without BOM:
Alternatively, use a command-line tool to strip the BOM:
sed -i '1s/^\xEF\xBB\xBF//' file.php