I am very new to PHP as this is the first time I am using it to develop a tool. Basically, I have been surfing the web for functions that are capable of extracting HTTP request header information and so far all I have been able to find are functions that return the word array. I know this is definitely me misunderstanding how to use the function and or arrays but a little clarity would be nice.
function emu_getallheaders() {
foreach ($_SERVER as $name => $value)
{
if (substr($name, 0, 5) == 'HTTP_')
{
$name = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))));
$headers[$name] = $value;
} else if ($name == "CONTENT_TYPE") {
$headers["Content-Type"] = $value;
} else if ($name == "CONTENT_LENGTH") {
$headers["Content-Length"] = $value;
}
}
return $headers;
}
echo emu_getallheaders();