Tuesday, 12 May 2020

PHP Output buffer

You can not modify header when starting to send out /outputing content to client,

use output buffer to modify header:

<?php
    ob_start( );
    echo "Hello World";
    if ( $some_error )
    {
        header( "Location: error.php" );
        exit( 0 );
    }
    $output = ob_get_clean( );
   echo $output
?>

https://stackoverflow.com/questions/2832010/what-is-output-buffering

No comments:

Post a Comment