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_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: It seems a bit 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 */