Server Information $ _ server []

Source: Internet
Author: User

 

1. $ _ ServerIs an array containing headers, paths, and script locations. The object of the array is created by the Web server. It is not guaranteed that all servers can generate all information.

<? PHP
Echo "http_user_agent:". $ _ server [Http_user_agent]. "<Br>"; // user_agent of the current request: Content in the header. Mozilla/4.0 (...

Echo "php_self:". $ _ server [Php_self]. "<Br>"; // file name path of the script being executed, relative to document root. /Test. php

Echo "SERVER_NAME:". $ _ server [SERVER_NAME]. "<Br>"; // host name, DNS alias, or IP address. Localhost

Echo "server_software:". $ _ server [Server_software]. "<Br>"; // string of the server ID. Apache/2.2.4 (win32 )...

Echo "QUERY_STRING:". $ _ server [QUERY_STRING]. "<Br>"; // query string. Haha = 33

Echo "document_root:". $ _ server [Document_root]. "<Br>"; // the root directory of the document where the script is currently running. C:/XAMPP/htdocs

Echo "http_host:". $ _ server [Http_host]. "<Br>"; // host of the current request: Content in the header. Localhost

Echo "remote_addr:". $ _ server [Remote_addr]. "<Br>"; // request the IP address of the machine on this page. 127.0.0.1

Echo "remote_host:". $ _ server [Remote_host]. "<Br>"; // request the host name of the machine on this page. If the machine does not have a DNS record, the variable is null.

Echo "http_referer:". $ _ server [Http_referer]. "<Br>"; // the browser comes to the previous page of the current page, which is empty

Echo "script_name:". $ _ server [Script_name]. "<Br>"; // path containing the current script. This is useful when the page needs to point to itself. Test/test. php

Echo "script_filename:". $ _ server [Script_filename]. "<Br>"; // the absolute path name of the currently executed script. C:/XAMPP/htdocs/test. php

?>

2. Differences between script_name and php_self

From: http://www.sonyfeel.com/doc.php? Action = view & docId = 9

on the current machine, the website $ _ server ['script _ name'] and $ _ server ['php _ Self '] are usually unavailable, because most PHP does not run in CGI Mode.
but dreamhost PHP runs in CGI mode, and the difference between the two is obvious.
echo $ _ server ['script _ name']; // (/cgi-system/PHP. CGI)
echo $ _ server ['php _ Self ']; // (/admin/test. PHP)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.