Skip to content

Clarify the output buffering note on the header() page - #5915

Merged
lacatoire merged 2 commits into
php:masterfrom
angeliszotis:doc/header-note-clarification
Oct 7, 2026
Merged

lacatoire merged 2 commits into
php:masterfrom
angeliszotis:doc/header-note-clarification

Conversation

@angeliszotis

Copy link
Copy Markdown
Contributor

Fixes #2680

The first note in the Notes section of the header() page reads:

You can use output buffering to get around this problem, with the overhead of all of your output to the browser being buffered in the server until you send it.

There is no problem mentioned before it. The note that comes right before is the SAPI one, which comes from the note.network.header.sapi entity:

Headers will only be accessible and output when a SAPI that supports them is in use.

so a reader going through the Notes section has nothing to attach "this problem" to. What it refers to is in the Description section:

Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP.

As the reporter pointed out, that is also not really a "problem" by itself. It is a requirement, and it only becomes a problem if something is output by accident.

I rewrote the opening clause so the note stands on its own:

Output buffering can be used to avoid the requirement that nothing is output before header() is called, with the overhead of all of your output to the browser being buffered in the server until you send it.

The rest of the note, the part about ob_start(), ob_end_flush() and output_buffering, is unchanged.

The first note in the Notes section starts with "You can use output
buffering to get around this problem", but there is no problem mentioned
anywhere before it. The note that comes before it is the one about SAPI
support, and the paragraph it actually refers to is in the Description
section, where it says that header() must be called before any output is
sent.

Rewrote the opening so the note says what it is about without depending
on a paragraph in another section. The rest of the note is unchanged.
@lacatoire

Copy link
Copy Markdown
Member

Thanks @angeliszotis, few linter nits, but LGTM

The DocBook style check flagged the note's para as inline-only.
@angeliszotis

Copy link
Copy Markdown
Contributor Author

Thanks @lacatoire! Switched the note to simpara to clear the style check.

@lacatoire
lacatoire merged commit 230f38e into php:master Oct 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Note on page for header() needs clarification.

2 participants