PHP get URL full path and physical path _php tutorial

Source: Internet
Author: User
Tags php get url
PHP's predefined variable, $_server, is an array of headers (headers), path information, and the location of the script, and the entity of the array is created by the Web server.
Using the $_server array, we can get the URL full path and the real path, let oneself use them arbitrarily.
$_server[' server_name '///The name of the server host where the script is currently running.
$_server[server_port ')//The port used by the user when connecting to the server.
$_server[' Request_uri '///currently running the script except for the host name of the request URL.
$_server[' document_root '///the document root directory where the script is currently running.
Example url:http://www.cndong.cn/test/test.php
$_server[' server_name ': www.cndong.cn
$_server[' Server_port ': 80www.2cto.com
$_server[' Request_uri ':/test/test.php
$_server[' document_root ':/home/var/www/cndong.cn/htdocs
So the URL full path is "http://". $_server[' server_name '].$_server[' Request_uri ']
Description
1. The default HTTP port is 80, so General $_server[' Server_port '] does not include URL full path, of course special case, special treatment!
2. Someone will use $_server[' remote_host ' to get the hostname, but it means: Browsing the host name of the current page user (this variable must be created by the Web server).
Extended:
$_server[' Remote_host ' is a workaround for null values
Modify hostnamelookups in Apache server configuration file httpd.conf to On

Author: Xu Xiujun

http://www.bkjia.com/PHPjc/478162.html www.bkjia.com true http://www.bkjia.com/PHPjc/478162.html techarticle PHP's predefined variable, $_server, is an array of headers (headers), path information, and the location of the script, and the entity of the array is created by the Web server. Using the $_server array, we can get the URL end ...

  • 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.