首页 > php教程 > php手册 > 例子:用getenv函数获取各种CGI环境变量

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

WBOY
发布: 2016-06-21 09:13:33
原创
1286 人浏览过

cgi|变量|函数


$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 '';
echo '';
echo '';

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

echo '
CGI Environment Variables
Name Value
$array[$i] " . $value . "
$array[$i] " . $$array[$i] . "
';
echo '
';
?>



相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门推荐
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板