Skip to content

Instantly share code, notes, and snippets.

@jasondewitt
Created May 9, 2016 21:58
Show Gist options
  • Save jasondewitt/d81c24de8d798d20370a2eb9fa7ddcac to your computer and use it in GitHub Desktop.
Save jasondewitt/d81c24de8d798d20370a2eb9fa7ddcac to your computer and use it in GitHub Desktop.
dump all headers in php
<?php
if (!function_exists('getallheaders')) {
function getallheaders()
{
if (!is_array($_SERVER)) {
return array();
}
$headers = array();
foreach ($_SERVER as $name => $value) {
if (substr($name, 0, 5) == 'HTTP_') {
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
}
}
return $headers;
}
}
$headers = getallheaders();
foreach($headers as $key=>$val){
echo $key . ': ' . $val . '<br>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment