Created
April 28, 2011 06:39
-
-
Save trylik/945915 to your computer and use it in GitHub Desktop.
Bypassing apache_request_headers() for phpunit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function request_headers() | |
{ | |
if(function_exists("apache_request_headers")) // If apache_request_headers() exists... | |
{ | |
if($headers = apache_request_headers()) // And works... | |
{ | |
return $headers; // Use it | |
} | |
} | |
$headers = array(); | |
foreach(array_keys($_SERVER) as $skey) | |
{ | |
if(substr($skey, 0, 5) == "HTTP_") | |
{ | |
$headername = str_replace(" ", "-", ucwords(strtolower(str_replace("_", " ", substr($skey, 0, 5))))); | |
$headers[$headername] = $_SERVER[$skey]; | |
} | |
} | |
return $headers; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment