Ralf Hohoff

Cannot modify header information

Bei der Umsetzung für ein CRM-Projekt erhielt ich die Fehlermeldung „Cannot modify header information – headers already sent by…“.
Die einschlägige Google-Suche brachte folgende Ergebnisse:

The problem? White space after the closing ?> PHP tag. You can have as many carriage returns as you like, but don’t try a space.

This error occurs if there is any output before calling header() function. The most common and mostly „invisible“ mistake is having whitespaces at the beginning or the end of one or more of your files. Make sure there are none before opening < ?php or after closing ?> tags.

Das war’s aber nicht, die Lösung war die UTF-Codierung des Quellcodes:

Another very common problem is extra whitespace at the *start* of php files – especially editors inserting invisibly UTF BOM bytes. If you want to make a maintenance tool, it would be good to check for this issue too.

In diesem Fall ist die PHP-Datei in UTF-8-Codierung abgepeichert und enthält ein “Byte Order Mark” (kurz: BOM). Das BOM-Steuerzeichen wird von PHP falsch erkannt, weshalb man für diese Datei “UTF-8 ohne BOM” als Kodierung wählen muss.

Danach funktioniert’s!

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

This website stores cookies on your computer. These cookies are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to to opt-out of any future tracking, a cookie will be setup in your browser to remember this choice for one year.

Accept or Deny