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 ^