| px | top | add code | search | signup | login | help |
<?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;
}
?>
Comments or questions?
PX is running PHP 5.2.11
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.