Get URL full path program code in PHP

Source: Internet
Author: User

Example url:http://www.111cn.net/test/test.php

The code is as follows Copy Code

$_server[' server_name ']: www.111cn.net

$_server[' Server_port ': 80

$_server[' Request_uri ']:/test/test.php

Then we can combine the above sentences to make it happen.

The full URL path is:

The code is as follows Copy Code
"http://". $_server[' server_name '].$_server[' Request_uri '

If you are opening the port number, we can use $_server[' Server_port ', the above code to modify it.

The code is as follows Copy Code
"http://". $_server[' server_name '. ': '. $_server[' server_port '].$_server[' ' Request_uri ']

We should pay attention to one point.

$_server[' Php_selft '] differs from the $_server[' Script_name ' and $_server[' Request_uri ' and $_server[' query_string ']:

$_server[' php_self ' returns/PHPTOUR/TEST7.PHP/A=B and returns the file name/following
$_server[' Script_name ' only returns/phptour/ test.php, does not return the content after the file name
http://localhost:60/phptour/test/test7.php/a=b
$_server[' php_self '] will get:/ Phptour/test/test7.php/a=b
$_server[' script_name '] will get:/phptour/test/test7.php
$_server[' REQUEST_URI '] will get :/phptour/test/test7.php/a=b
$_server[' query_string '] will get: '

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.