note 72498 deleted from function.apache-request-headers by peehaa

From: Date: Sun, 08 Sep 2013 14:32:38 +0000
Subject: note 72498 deleted from function.apache-request-headers by peehaa
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-196194@lists.php.net to get a copy of this message
Note Submitter: jrabbit ---- The following code will implement an approximation of apache_request_headers for lighttpd making most scripts that use the function portable between the two platforms. Caveats are: 1. This function will convert any _ in a header key to a - 2. This function will capitalize the first character and first character after each hyphen in each header key and lower case the rest of the key. This does not cause a problem with standard headers which are capitalized in this manner but may cause custom headers to appear in a different case to apache. <?php if (!function_exists('apache_request_headers')) { eval(' 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; } } return $out; } '); } ?>

« previous php.notes (#196194) next »