Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check whether header() has been set in PHP?

Is there possible whether there are some header information set so far in PHP?

like image 604
user198729 Avatar asked Aug 29 '10 06:08

user198729


2 Answers

Try headers_sent().

PHP docs on headers_sent().

You can also retrieve the headers for a page with get_headers() and list them with headers_list(). I'm a bit confused though, do you mean you want to check if something like header("Location: /path/to/location"); has been called?

like image 50
Josh K Avatar answered Oct 27 '22 23:10

Josh K


Try using header_list() to determine what headers are ready to be sent to the client. Use headers_sent() to check if headers have been sent to the client.

like image 23
muxare Avatar answered Oct 28 '22 00:10

muxare