Get server-related information in PHP ($_SERVER)

WBOY
Release: 2016-07-29 09:11:50
Original
918 people have browsed it

The most commonly used

<code><span>$_SERVER</span>[<span>'HTTP_ACCEPT_LANGUAGE'</span>]<span>//浏览器语言 </span><span>$_SERVER</span>[<span>'REMOTE_ADDR'</span>] <span>//当前用户 IP 。 </span><span>$_SERVER</span>[<span>'REMOTE_HOST'</span>] <span>//当前用户主机名 </span><span>$_SERVER</span>[<span>'REQUEST_URI'</span>] <span>//URL</span></code>
Copy after login

<code><span>$_SERVER</span>[<span>'REMOTE_PORT'</span>] <span>//端口。 </span><span>$_SERVER</span>[<span>'SERVER_NAME'</span>] <span>//服务器主机的名称。 </span><span>$_SERVER</span>[<span>'PHP_SELF'</span>]<span>//正在执行脚本的文件名 </span><span>$_SERVER</span>[<span>'argv'</span>] <span>//传递给该脚本的参数。 </span><span>$_SERVER</span>[<span>'argc'</span>] <span>//传递给程序的命令行参数的个数。 </span><span>$_SERVER</span>[<span>'GATEWAY_INTERFACE'</span>]<span>//CGI 规范的版本。 </span><span>$_SERVER</span>[<span>'SERVER_SOFTWARE'</span>] <span>//服务器标识的字串 </span><span>$_SERVER</span>[<span>'SERVER_PROTOCOL'</span>] <span>//请求页面时通信协议的名称和版本 </span><span>$_SERVER</span>[<span>'REQUEST_METHOD'</span>]<span>//访问页面时的请求方法 </span><span>$_SERVER</span>[<span>'QUERY_STRING'</span>] <span>//查询(query)的字符串。 </span><span>$_SERVER</span>[<span>'DOCUMENT_ROOT'</span>] <span>//当前运行脚本所在的文档根目录 </span><span>$_SERVER</span>[<span>'HTTP_ACCEPT'</span>] <span>//当前请求的 Accept: 头部的内容。 </span><span>$_SERVER</span>[<span>'HTTP_ACCEPT_CHARSET'</span>] <span>//当前请求的 Accept-Charset: 头部的内容。 </span><span>$_SERVER</span>[<span>'HTTP_ACCEPT_ENCODING'</span>] <span>//当前请求的 Accept-Encoding: 头部的内容 </span><span>$_SERVER</span>[<span>'HTTP_CONNECTION'</span>] <span>//当前请求的 Connection: 头部的内容。例如:“Keep-Alive”。 </span><span>$_SERVER</span>[<span>'HTTP_HOST'</span>] <span>//当前请求的 Host: 头部的内容。 </span><span>$_SERVER</span>[<span>'HTTP_REFERER'</span>] <span>//链接到当前页面的前一页面的 URL 地址。 </span><span>$_SERVER</span>[<span>'HTTP_USER_AGENT'</span>] <span>//当前请求的 User_Agent: 头部的内容。 </span><span>$_SERVER</span>[<span>'HTTPS'</span>]<span>//如果通过https访问,则被设为一个非空的值(on),否则返回off </span><span>$_SERVER</span>[<span>'SCRIPT_FILENAME'</span>] <span>#当前执行脚本的绝对路径名。 </span><span>$_SERVER</span>[<span>'SERVER_ADMIN'</span>] <span>#管理员信息 </span><span>$_SERVER</span>[<span>'SERVER_PORT'</span>] <span>#服务器所使用的端口 </span><span>$_SERVER</span>[<span>'SERVER_SIGNATURE'</span>] <span>#包含服务器版本和虚拟主机名的字符串。 </span><span>$_SERVER</span>[<span>'PATH_TRANSLATED'</span>] <span>#当前脚本所在文件系统(不是文档根目录)的基本路径。 </span><span>$_SERVER</span>[<span>'SCRIPT_NAME'</span>] <span>#包含当前脚本的路径。这在页面需要指向自己时非常有用。 </span><span>$_SERVER</span>[<span>'PHP_AUTH_USER'</span>] <span>#当 PHP 运行在 <strong>Apache</strong> 模块方式下,并且正在使用 HTTP 认证功能,这个变量便是用户输入的用户名。 </span><span>$_SERVER</span>[<span>'PHP_AUTH_PW'</span>] <span>#当 PHP 运行在 <strong>Apache</strong> 模块方式下,并且正在使用 HTTP 认证功能,这个变量便是用户输入的密码。 </span><span>$_SERVER</span>[<span>'AUTH_TYPE'</span>] <span>#当 PHP 运行在 <strong>Apache</strong> 模块方式下,并且正在使用 HTTP 认证功能,这个变量便是认证的类型</span></code>
Copy after login
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces the relevant information about obtaining the server ($_SERVER) in PHP, including Apache content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!