PHP gets the URL of the current script case

Source: Internet
Author: User
Tags ssl connection

About getting the URL of the current script in PHP many friends will say it is simple, but to get a very detailed will have to go through 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 ']);
/**
Gets the name of the currently running script: it's a little messy at first. I don't use if else. Look at something like that. We'd better see left from right. It's better to understand. $_server[' script_name '] $_server[' php_self '] $_server[' orig_path_info '] These three server global variables are the names of the current scripts. Mainly look at the current environment of the server. The one that exists, gets that.
The Isset () function is useful. Tests whether a variable is already defined. Note: $a = NULL; Isset ($a) 2881064151 This will return false for OH. Note the use of isset and empty two functions. It's a big problem to use well. Read the manual 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 '] = = ' 443 '? ' https://': '/HTTP '; Test whether the server initiates an SSL connection if it is. Use the https://secure connection to pass
$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: ");
/**
Gets the URL of the current script
*/

PHP gets the URL of the current script case

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.