Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

178
Views
When does php prepare to send headers?

I wish to review and change headers before they are sent & also be able to stop any content from being send if headers are not to my liking or other conditions are not met.

When I set a function for header_register_callback, the headers can be adjusted perfectly. However, when using a die() statement in the callback, it does not prevent the triggering statement from being outputted. This appears only to be an issue in php 8.0.0 - 8.0.10

Looking at the description of the header register callback: "The callback is executed just after PHP prepares all headers to be sent, and before any other output is sent, creating a window to manipulate the outgoing headers before being sent."

Why does the below example still output:

In php 8.0.0 - 8.0.10, a die statement does prevent the trigger from being outputted: Trigger.

as opposed to:

In php 8.0.0 - 8.0.10, a die statement does prevent the trigger from being outputted:

<?php
    ob_start(); // make sure ob_level is set to 1

    function callback()
    {
        echo "In php 8.0.0 - 8.0.10, a die statement does prevent the trigger from being outputted: ";
        die();
    }
    header_register_callback("callback");

    ob_end_clean();
    echo "Trigger.";
    echo "Execution died before this echo statement.";

I've made a bug report about this as well on: https://bugs.php.net/bug.php?id=81431 Example snippet: https://3v4l.org/0NITj

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!