Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

180
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda