home *** CD-ROM | disk | FTP | other *** search
- get_headers
-
- An alternative to the get_all_headers() function for those who either don't have Apache, or are running PHP3 as a CGI
-
-
- <?php
-
- #
- #
- # arr_get_headers()
- # Returns an associative array of client request headers
- #
- # str_get_headers()
- # Returns a string of the form 'var: val\n' containing the
- # client request headers. It is meant as an example for those who
- # do not want the overhead of parsing the headers twice.
- #
- #
- # Todo:
- # - Parse or remove HTTP_GET_VARS, HTTP_POST_VARS and HTTP_COOKIE_VARS
- # if they exist.
- #
- # v0.1
- # 2000/03/15
- # James Corbett
- #
- #
- function arr_get_headers() {
- while ( list( $var, $val) = each( $GLOBALS)) {
- if ( substr( $var, 0, 4) == "HTTP") {
- $headers[$var] = $val;
- }
- }
- return $headers;
- }
-
- function str_get_headers() {
- $headers = "";
- while ( list( $var, $val) = each( $GLOBALS)) {
- if ( substr( $var, 0, 4) == "HTTP") {
- $headers .= sprintf( "%s: %s\n", $var, $val);
- }
- }
- return $headers;
- }
-
- ?>
-