reserved.variables.server.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 742 行 · 第 1/2 页
HTML
742 行
</dd> </dt> <dt> <span class="term">'<var class="varname">HTTPS</var>'</span> <dd> <span class="simpara"> Set to a non-empty value if the script was queried through the HTTPS protocol. </span> <span class="simpara"> Note that when using ISAPI with IIS, the value will be <i>off</i> if the request was not made through the HTTPS protocol. </span> </dd> </dt> <dt> <span class="term">'<var class="varname">REMOTE_ADDR</var>'</span> <dd> <span class="simpara"> The IP address from which the user is viewing the current page. </span> </dd> </dt> <dt> <span class="term">'<var class="varname">REMOTE_HOST</var>'</span> <dd> <span class="simpara"> The Host name from which the user is viewing the current page. The reverse dns lookup is based off the <var class="varname">REMOTE_ADDR</var> of the user. </span> <blockquote><p><b class="note">Note</b>: <span class="simpara"> Your web server must be configured to create this variable. For example in Apache you'll need <i>HostnameLookups On</i> inside <var class="filename">httpd.conf</var> for it to exist. See also <a href="function.gethostbyaddr.html" class="function">gethostbyaddr()</a>. </span> </p></blockquote> </dd> </dt> <dt> <span class="term">'<var class="varname">REMOTE_PORT</var>'</span> <dd> <span class="simpara"> The port being used on the user's machine to communicate with the web server. </span> </dd> </dt> <dt> <span class="term">'<var class="varname">SCRIPT_FILENAME</var>'</span> <dd> <p class="para"> The absolute pathname of the currently executing script. <blockquote><p><b class="note">Note</b>: If a script is executed with the CLI, as a relative path, such as <var class="filename">file.php</var> or <var class="filename">../file.php</var>, <var class="varname">$_SERVER['SCRIPT_FILENAME']</var> will contain the relative path specified by the user. <br /> </p></blockquote> </p> </dd> </dt> <dt> <span class="term">'<var class="varname">SERVER_ADMIN</var>'</span> <dd> <span class="simpara"> The value given to the SERVER_ADMIN (for Apache) directive in the web server configuration file. If the script is running on a virtual host, this will be the value defined for that virtual host. </span> </dd> </dt> <dt> <span class="term">'<var class="varname">SERVER_PORT</var>'</span> <dd> <span class="simpara"> The port on the server machine being used by the web server for communication. For default setups, this will be '<i>80</i>'; using SSL, for instance, will change this to whatever your defined secure HTTP port is. </span> </dd> </dt> <dt> <span class="term">'<var class="varname">SERVER_SIGNATURE</var>'</span> <dd> <span class="simpara"> String containing the server version and virtual host name which are added to server-generated pages, if enabled. </span> </dd> </dt> <dt> <span class="term">'<var class="varname">PATH_TRANSLATED</var>'</span> <dd> <span class="simpara"> Filesystem- (not document root-) based path to the current script, after the server has done any virtual-to-real mapping. </span> <blockquote><p><b class="note">Note</b>: <span class="simpara"> As of PHP 4.3.2, <span class="envar">PATH_TRANSLATED</span> is no longer set implicitly under the Apache 2 <acronym title="Server Application Programming Interface">SAPI</acronym> in contrast to the situation in Apache 1, where it's set to the same value as the <span class="envar">SCRIPT_FILENAME</span> server variable when it's not populated by Apache. This change was made to comply with the <acronym title="Common Gateway Interface">CGI</acronym> specification that <span class="envar">PATH_TRANSLATED</span> should only exist if <span class="envar">PATH_INFO</span> is defined. </span> <span class="simpara"> Apache 2 users may use <i>AcceptPathInfo = On</i> inside <var class="filename">httpd.conf</var> to define <span class="envar">PATH_INFO</span>. </span> </p></blockquote> </dd> </dt> <dt> <span class="term">'<var class="varname">SCRIPT_NAME</var>'</span> <dd> <span class="simpara"> Contains the current script's path. This is useful for pages which need to point to themselves. The <a href="language.constants.predefined.html" class="link">__FILE__</a> constant contains the full path and filename of the current (i.e. included) file. </span> </dd> </dt> <dt> <span class="term">'<var class="varname">REQUEST_URI</var>'</span> <dd> <span class="simpara"> The URI which was given in order to access this page; for instance, '<i>/index.html</i>'. </span> </dd> </dt> <dt> <span class="term">'<var class="varname">PHP_AUTH_DIGEST</var>'</span> <dd> <span class="simpara"> When running under Apache as module doing Digest HTTP authentication this variable is set to the 'Authorization' header sent by the client (which you should then use to make the appropriate validation). </span> </dd> </dt> <dt> <span class="term">'<var class="varname">PHP_AUTH_USER</var>'</span> <dd> <span class="simpara"> When running under Apache or IIS (ISAPI on PHP 5) as module doing HTTP authentication this variable is set to the username provided by the user. </span> </dd> </dt> <dt> <span class="term">'<var class="varname">PHP_AUTH_PW</var>'</span> <dd> <span class="simpara"> When running under Apache or IIS (ISAPI on PHP 5) as module doing HTTP authentication this variable is set to the password provided by the user. </span> </dd> </dt> <dt> <span class="term">'<var class="varname">AUTH_TYPE</var>'</span> <dd> <span class="simpara"> When running under Apache as module doing HTTP authenticated this variable is set to the authentication type. </span> </dd> </dt> </dl> </p> </div> <div class="refsect1 changelog"> <h3 class="title">ChangeLog</h3> <p class="para"> <table class="informaltable"> <colgroup> <thead valign="middle"> <tr valign="middle"> <th colspan="1">Version</th> <th colspan="1">Description</th> </tr> </thead> <tbody valign="middle" class="tbody"> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">4.1.0</td> <td colspan="1" rowspan="1" align="left"> Introduced <var class="varname">$_SERVER</var> that the deprecated <var class="varname">$HTTP_SERVER_VARS</var>. </td> </tr> </tbody> </colgroup> </table> </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="variable.server.basic" name="variable.server.basic"> <p><b>Example #1 <var class="varname">$_SERVER</var> example</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$_SERVER</span><span style="color: #007700">[</span><span style="color: #DD0000">'SERVER_NAME'</span><span style="color: #007700">];<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> <div class="example-contents"><p>The above example will output something similar to:</p></div> <div class="example-contents"><pre><div class="cdata"><pre>www.example.com</pre></div> </pre></div> </div> </p> </div> <div class="refsect1 notes"> <h3 class="title">Notes</h3> <blockquote><p><b class="note">Note</b>: This is a 'superglobal', orautomatic global, variable. This simply means that it is available inall scopes throughout a script. There is no need to do <strong class="command">global $variable;</strong> to access it within functions or methods.<br /></p></blockquote> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="book.filter.html" class="link">The filter extension</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="reserved.variables.globals.html">$GLOBALS</a></div> <div class="next" style="text-align: right; float: right;"><a href="reserved.variables.get.html">$_GET</a></div> <div class="up"><a href="reserved.variables.html">Predefined variables</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?