PHP generates HTML pure static web page code

Source: Internet
Author: User
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 ^

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.