<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >nsapi_request_headers</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="PHP 手册" HREF="index.html"><LINK REL="UP" TITLE="NSAPI-specific Functions" HREF="ref.nsapi.html"><LINK REL="PREVIOUS" TITLE="NSAPI-specific Functions" HREF="ref.nsapi.html"><LINK REL="NEXT" TITLE="nsapi_response_headers" HREF="function.nsapi-response-headers.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP 手册</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="ref.nsapi.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.nsapi-response-headers.html" ACCESSKEY="N" >下一页</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.nsapi-request-headers" ></A >nsapi_request_headers</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN155373" ></A ><P > (PHP 4 >= 4.3.3, PHP 5)</P >nsapi_request_headers -- Fetch all HTTP request headers</DIV ><DIV CLASS="refsect1" ><A NAME="AEN155376" ></A ><H2 >说明</H2 >array <B CLASS="methodname" >nsapi_request_headers</B > ( void )<BR ></BR ><P > <B CLASS="function" >nsapi_request_headers()</B > gets all the HTTP headers in the current request. This is only supported when PHP runs as a <SPAN CLASS="productname" >NSAPI</SPAN > module. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >注意: </B > Prior to PHP 4.3.3, <A HREF="function.getallheaders.html" ><B CLASS="function" >getallheaders()</B ></A > was only available for the Apache servers. After PHP 4.3.3, <A HREF="function.getallheaders.html" ><B CLASS="function" >getallheaders()</B ></A > is an alias for <B CLASS="function" >nsapi_request_headers()</B > if you use the NSAPI module. </P ></BLOCKQUOTE ></DIV ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >注意: </B > You can also get at the value of the common CGI variables by reading them from the <TT CLASS="literal" >$_SERVER</TT > superglobal, which works whether or not you are using PHP as a <SPAN CLASS="productname" >NSAPI</SPAN > module. </P ></BLOCKQUOTE ></DIV ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN155394" ></A ><H2 >返回值</H2 ><P > Returns an associative array with all the HTTP headers. </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN155397" ></A ><H2 >范例</H2 ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN155400" ></A ><P ><B >例 1. <B CLASS="function" >nsapi_request_headers()</B > example</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br />$headers </font><font color="#007700">= </font><font color="#0000BB">nsapi_request_headers</font><font color="#007700">();<br /><br />foreach (</font><font color="#0000BB">$headers </font><font color="#007700">as </font><font color="#0000BB">$header </font><font color="#007700">=> </font><font color="#0000BB">$value</font><font color="#007700">) {<br /> echo </font><font color="#DD0000">"$header: $value <br /></font><font color="#007700">\n</font><font color="#DD0000">"</font><font color="#007700">;<br />}<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="ref.nsapi.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >起始页</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.nsapi-response-headers.html" ACCESSKEY="N" >下一页</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >NSAPI-specific Functions</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.nsapi.html" ACCESSKEY="U" >上一级</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >nsapi_response_headers</TD ></TR ></TABLE ></DIV ></BODY ></HTML >