Skip to content

Instantly share code, notes, and snippets.

@cawa0505
Forked from hmert/nginx_request_headers.php
Created November 7, 2018 12:24
Show Gist options
  • Save cawa0505/da57470259d642be7671e6b4b52365b1 to your computer and use it in GitHub Desktop.
Save cawa0505/da57470259d642be7671e6b4b52365b1 to your computer and use it in GitHub Desktop.
// apache_request_headers replicement for nginx
if (!function_exists('apache_request_headers')) {
function apache_request_headers() {
foreach($_SERVER as $key=>$value) {
if (substr($key,0,5)=="HTTP_") {
$key=str_replace(" ","-",ucwords(strtolower(str_replace("_"," ",substr($key,5)))));
$out[$key]=$value;
}else{
$out[$key]=$value;
}
}
return $out;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment