Php retrieves the url of the current script

Source: Internet
Author: User
Tags ssl connection
Many friends may say that it is very easy to use php to obtain the url of the current script. however, to obtain the url in details, you must make multiple judgments. $ PHP_TIMEtime (); $ PHP_SELFnbsp... a lot of friends may say that it is very simple to get the url of the current script using php, but it should be judged several times to obtain details.

$ PHP_TIME = time (); $ PHP_SELF = isset ($ _ SERVER ['php _ SELF '])? $ _ SERVER ['php _ SELF ']: (isset ($ _ SERVER ['script _ name'])? $ _ SERVER ['script _ name']: $ _ SERVER ['orig _ PATH_INFO ']);/** get the NAME of the currently running SCRIPT: Check whether the SCRIPT is messy at the beginning. If else is useless. Look at this. We 'd better see the left from the right. This is clear. $ _ SERVER ['script _ name'] $ _ SERVER ['php _ SELF '] $ _ SERVER ['orig _ PATH_INFO'] These three global variables are used to obtain the current SCRIPT.. It mainly depends on the current server environment. The one that exists gets the one. The isset () function is very useful. Test whether a variable has been defined. Note: $ a = NULL; isset ($ a) will return false. Pay attention to the usage of isset and empty functions. If it is not used properly, it will cause major problems. Read the manual by yourself. */$ PHP_QUERYSTRING = $ _ SERVER ['query _ string']; $ PHP_DOMAIN = $ _ SERVER ['server _ name']; $ PHP_REFERER = isset ($ _ SERVER ['http _ referer'])? $ _ SERVER ['http _ referer']: ''; $ PHP_SCHEME = $ _ SERVER ['server _ port'] = '2016 '? 'Https: // ': 'http: //'; // test whether the server has enabled the ssl connection. Use https: // for secure connection $ PHP_PORT =$ _ SERVER ['server _ port'] = '80 '? '':':'. $ _ SERVER ['server _ port']; $ PHP_SITEURL = $ PHP_SCHEME. $ PHP_DOMAIN. $ PHP_PORT.PHPCMS_PATH; $ PHP_URL = $ PHP_SCHEME. $ PHP_DOMAIN. $ PHP_PORT. $ PHP_SELF. ($ PHP_QUERYSTRING? '? '. $ PHP_QUERYSTRING: '');/** get the URL of the current script */


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.