note 73964 added to function.apache-request-headers

From: Date: Sun, 18 Mar 2007 16:03:14 +0000
Subject: note 73964 added to function.apache-request-headers
Groups: php.notes 
Request: Send a blank email to php-notes+get-124573@lists.php.net to get a copy of this message
I wrote a function similar to jrabbit's, except that mine creates a custom function rather than redefining the original. <?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; } ?> Also, eval() is not necessary to define a function that is within an if block, as is done in jrabbit's code, because PHP will only read the function if it passes the if condition. ---- Server IP: 69.147.83.197 Probable Submitter: 75.0.33.76 ---- Manual Page -- http://www.php.net/manual/en/function.apache-request-headers.php Edit -- https://master.php.net/note/edit/73964 Del: integrated -- https://master.php.net/note/delete/73964/integrated Del: useless -- https://master.php.net/note/delete/73964/useless Del: bad code -- https://master.php.net/note/delete/73964/bad+code Del: spam -- https://master.php.net/note/delete/73964/spam Del: non-english -- https://master.php.net/note/delete/73964/non-english Del: in docs -- https://master.php.net/note/delete/73964/in+docs Del: other reasons-- https://master.php.net/note/delete/73964 Reject -- https://master.php.net/note/reject/73964 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#124573) next »