Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

179
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda