php / php/doc-en

headers_sent(&$filename, &$linenum) returns true and yet doesn't set either filename or linenum

Open
#2,523 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Extension: standard Status: Needs Triage
Dominant language
XML
Stars
596
Forks
890
Avg merge
1d 15h
Merged PRs (30d)
55

Description

From manual page: https://php.net/function.headers-sent


It says:

If the optional filename and line parameters are set, headers_sent() will put the PHP source file name and line number where output started in the filename and line variables.

Therefore, if I call headers_sent($filename, $linenum) and pass it both arguments, and it returns true, I expect it to set both filename and linenum to the file and line number where the output started.

And yet, I (pretty often) observe cases where it returns true and yet doesn't set filename and line number. I don't know how to reproduce, because, because of the very fact that it doesn't tell me where the output started, I have been unable to debug it. Otherwise I would be happy to provide example code that reproduces.

If there are legitimate cases for headers_sent() being unable to tell the file name and line number where the output started, then these cases should be documented in excruciating detail.

But I can't think of any such legitimate cases. My script is initiated by a php file, so wherever the output started, that "somewhere" MUST be at least backtraceable to some filename and line number (if it was started by eval()'d code, then it's the filename and line number that called eval(), that is given that you decided that only a filename and line number are to be returned and not a backtrace of any sort).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the headers_sent() manual page linked in the issue and review its current description of the optional filename and line parameters. Investigate the reported cases where the function returns true without populating them, then document confirmed limitations or correct the wording. Done means the manual page explains the behavior accurately and includes reproducible guidance where possible.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.