Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check whether content already sent in PHP

Is there a smart way to check whether output has already been sent to the browser and sending a header would generate a PHP_WARNING?

Obviously there's the alternative of using an output buffer, but that's not always an option.

like image 568
Alan Plum Avatar asked Apr 17 '09 11:04

Alan Plum


1 Answers

You can use the headers_sent() method. This because before anything is outputted, the headers will be send first.

like image 70
Peter Smit Avatar answered Sep 20 '22 03:09

Peter Smit