用getenv函数获取各种CGI环境变量

日期:2007-06-28  作者:喜腾小二  来源:PHPChina


$array =
array(
               "remote_addr",
               "document_root",
               "gateway_interface",
               "server_software",
               "server_name",
               "server_protocol",
               "server_port",
               "server_admin",
               "server_signature",
               "request_method",
               "request_uri",
               "path_info",
               "path_translated",
               "script_name",
               "script_filename",
               "query_string",
               "remote_host",
               "remote_addr",
               "remote_user",
               "remote_ident",
               "content_type",
               "content_length",
               "http_accept",
               "http_accept_charset",
               "http_accept_language",
               "http_encoding",
               "http_user_agent",
               "http_connection",
               "http_host",
               "http_referer",
               "auth_type"
              );

echo

;
echo cellpadding="0">;
echo ;
echo
;

$count =
count($array);
for($i=0;$i<$count;$i++){
   $value =
getenv($array[$i]);
   if($value){
      echo
"";
   }
//下面的语句也可以哦
//   if(isset($$array[$i])){
//      echo
"";
//   }
}

echo
cgi environment
variables
namevalue
$array[$i]" . $value .
"
$array[$i]" . $$array[$i] .
"
;
echo
;
?>

<<<返回技术中心

技术文章

站内新闻

我要啦免费统计