Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get PHP to display the headers it received from a browser?

Tags:

http

php

header

Are they all stored in $_SERVER? Even custom ones?

like image 594
tehryan Avatar asked Sep 10 '09 06:09

tehryan


People also ask

How do I view headers in PHP?

The get_headers() function in PHP is used to fetch all the headers sent by the server in the response of an HTTP request.


2 Answers

Try this

print_r($_SERVER)

It will list everything within the array

like image 84
Steven Mercatante Avatar answered Sep 19 '22 07:09

Steven Mercatante


you can use getallheaders() to get an array of all HTTP headers sent.

$headers =  getallheaders(); foreach($headers as $key=>$val){   echo $key . ': ' . $val . '<br>'; } 
like image 39
aphoe Avatar answered Sep 21 '22 07:09

aphoe