-3

I want to display the received headers from the GET Request that I send,

PHP:

<?php
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:51.0) Gecko/20100101 Firefox/51.0"
));
$context = stream_context_create($opts);
$url = "http://spys.me/proxy.txt";
// instead of file_get_contents
$data = getallheaders($url, false, $context);

echo $data;
phong
  • 33
  • 1
  • 1
  • 8

2 Answers2

2

You can get all the headers like this

foreach (getallheaders() as $name => $value) {
    echo "$name: $value\n";
}
FULL STACK DEV
  • 15,207
  • 5
  • 46
  • 66
1

How about simple var_dump()?

var_dump(getallheaders());
Blcknx
  • 1,921
  • 1
  • 12
  • 38