# Unexpected characters  at the top of the page / headers already sent by BOM

**Code:** `BOM output` · **Category:** PHP · **Seen on:** PHP

A UTF-8 byte-order mark (BOM) at the start of a PHP file is sent as output, breaking headers, JSON and images.

## Meaning

Some editors save files with an invisible BOM (EF BB BF). PHP outputs it before your code runs. Symptoms: “headers already sent … output started at file.php:1”, JSON parse errors, corrupted downloads.

## Common causes

- File saved as “UTF-8 with BOM”
- Hosting control-panel editors adding a BOM
- Copy-pasted config from Windows tools

## Quick fix

1. Re-save the file as UTF-8 without BOM
2. Find BOMs: `grep -rlI $'^\xEF\xBB\xBF' .`
3. Remove closing `?>` tags from pure PHP files

## Detailed fix by platform

### Linux

1. `sed -i '1s/^\xEF\xBB\xBF//' file.php` removes a BOM

## How to diagnose

1. **Line 1** — Does the warning point to line 1 of a file?
2. **Bytes** — `head -c 3 file.php | xxd`

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/php/headers-already-sent-by-bom)
