BOM output PHP Origin: Application & API OSI layer 7 · Application Last updated 15 Oct 2026

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

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

Exact message you may see byte order mark
Seen on: PHP

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

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

100 — HTTP 100 Continue (HTTP)100103 — HTTP 103 Early Hints (HTTP)1031040 — Cloudflare Error 1040 / 1041: Invalid request header modification (Cloudflare)1040400 — 400 Bad Request: Request Header Or Cookie Too Large (HTTP)400400 — 400 Bad Request: invalid character in header (HTTP)400401 — 401 Unauthorized without WWW-Authenticate header (HTTP)401411 — HTTP 411 Length Required (HTTP)411414 Request-URI Too Large / 400 Request Header Or Cookie Too Large — Nginx: 400 Bad Request — Request Header Or Cookie Too Large / client sent too long header line (Nginx / Apache)414 Request-URI Too L…BOM output

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.