note 116645 added to function.apache-request-headers
| From: | egocentryk | Date: | Tue, 03 Feb 2015 23:13:40 +0000 |
| Subject: | note 116645 added to function.apache-request-headers | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-201586@lists.php.net to get a copy of this message | ||
Superglobal $_SERVER, used in all patches for missing getallheaders() contains only truly basic
headers. To pass ANY header into PHP in any httpd environment, including CGI/FCGI just add rule
(any number of rules) into .htaccess:
RewriteRule .* - [E=HTTP_MY_HEADER:%{HTTP:My-Header}]
and the header with it's value will appear for PHP as
<?php print $_SERVER['HTTP_MY_HEADER']; ?>
And... just couldn't hold off. Rewrtiting $_SERVER keys for replacing missing function really
does not require RegExps, preg_matches or evals... Try this:
<?php
function getallheaders() {
foreach($_SERVER as $K=>$V){$a=explode('_' ,$K);
if(array_shift($a)=='HTTP'){
array_walk($a,function(&$v){$v=ucfirst(strtolower($v));});
$retval[join('-',$a)]=$V;}
} return $retval; }
?>
----
Server IP: 72.52.91.14
Probable Submitter: 188.33.94.140
----
Manual Page -- http://php.net/manual/en/function.apache-request-headers.php
Edit -- https://master.php.net/note/edit/116645
Del: integrated -- https://master.php.net/note/delete/116645/integrated
Del: useless -- https://master.php.net/note/delete/116645/useless
Del: bad code -- https://master.php.net/note/delete/116645/bad+code
Del: spam -- https://master.php.net/note/delete/116645/spam
Del: non-english -- https://master.php.net/note/delete/116645/non-english
Del: in docs -- https://master.php.net/note/delete/116645/in+docs
Del: other reasons-- https://master.php.net/note/delete/116645
Reject -- https://master.php.net/note/reject/116645
Search -- https://master.php.net/manage/user-notes.php