In php, there is a global variable $ _ SERVER that comes with the system. There are many parameters in it. next I will introduce a friend who needs to get the complete URL path program code. example URL: www. phprm. comTestTe... in php, there is a global variable $ _ SERVER that comes with the system. There are many parameters in it. next I will introduce a friend who needs to get the complete URL path program code.
Example URL: http://www.phprm.com/test/test.php. the code is as follows:
$_SERVER['SERVER_NAME']:www.phprm.com $_SERVER['SERVER_PORT']:80 $_SERVER['REQUEST_URI']:/Test/Test.php
Then we can combine the above statements to achieve it. the complete URL path is:
"Http: //". $ _ SERVER ['server _ name']. $ _ SERVER ['request _ URI ']
If you have enabled the PORT number, you can use $ _ SERVER ['server _ port']. just modify the above code and the code is as follows:
"Http ://". $ _ SERVER ['server _ name']. ':'. $ _ SERVER ['server _ port']. $ _ SERVER ['request _ URI ']
Note the following:
$ _ SERVER ['php _ SELFT '] and $ _ SERVER ['script _ name'] and $ _ SERVER ['request _ URI'] and $ _ SERVER ['query _ STRING:
$ _ SERVER ['php _ SELF '] returns/phptour/test7.php/a = B, the file NAME/followed by $ _ SERVER ['script _ name'] will be returned, and only/phptour/test will be returned. php. 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 :''
Permanent address:
Reprint at will ~ Please bring the tutorial URL ^