Use ob_start() and ob_end_flush()?

by 3 replies
5
Should I use ob_start() at the beginning of every script that uses header('Location: file.php') and ob_end_flush()
at the end of that same script?
#programming #obendflush #obstart
  • If you want to surpress the output then yes, go for it.

    However... that header() command would re-direct the user to another page, thus no output would actually come anyway?

    In other words, you could have:

    <?php

    header('Location: NewPage.php');

    echo 'Blah';

    ?>

    However "Blah" would never get output since the user would get re-directed to NewPage.php?

    The output buffering functions are... well... to buffer the output As in, to delay the output of the HTML to the browser until you flush/end the output bufferer. I'm a little confused why you are thinking of using OB functions when you also intend to re-direct the user?
  • Actually the "echo" after the "header" might screw up the redirect and it might not execute.
  • I agree I was just pointing out that there's no real reason to use the OB functions when re-directing.

Next Topics on Trending Feed