How can the Byte Order Mark (BOM) affect PHP output and cause formatting issues?

The Byte Order Mark (BOM) is a special character that can be added to the beginning of a file to indicate its encoding. In PHP, if the BOM is present in the output, it can cause formatting issues such as unexpected characters or whitespace at the beginning of the output. To solve this issue, you can use the `ob_start()` function to buffer the output and remove any BOM characters before sending the output to the browser.

ob_start(function ($buffer) {
    return ltrim($buffer, "\xef\xbb\xbf");
});