Php obtains the url and parameters of the current page. Php obtains the url and parameters of the current page. to obtain the complete address of the current page, we need to perform many operations, such as the HTTP or HTTPSphp file and the host domain name query parameters. Php obtains the url and parameters of the current page. to obtain the complete address of the current page, we need to perform many operations, such as HTTP or HTTPS php file and host domain name query parameters. Get protocol-HTTP
Obtain the url and parameters of the current page in the php Tutorial.
To obtain the complete address of the current page, we need to perform many operations, such as http or https tutorial php file and path host domain name query parameters.
Get protocol-http
The url protocol can be read in the $ _ server ['server _ protocol'] variable.
*/
Echo $ _ server ['server _ protocol'];
/*
If you check the value, you can find that not only http or https, but such a string: http/1.1
*/
$ Protocol = strpos (strtolower ($ _ server ['server _ protocol']), 'https') = false? 'Http': 'https ';
/*
Get host domain name */
$ Host = $ _ server ['http _ host'];
/*
Use $ _ server ['script _ name'] to obtain the php file and path except the domain name
*/
$ Script = $ _ server ['script _ name'];
// Get? Query parameters later
$ Params = $ _ server ['query _ string'];
// Method 2
$ Uri = $ _ server ['request _ uri '];
// The following shows a complete example of getting the current url.
$ Protocol = strpos (strtolower ($ _ server ['server _ protocol']), 'https') = false? 'Http': 'https ';
$ Host = $ _ server ['http _ host'];
$ Script = $ _ server ['script _ name'];
$ Params = $ _ server ['query _ string'];
$ Currenturl = $ protocol. ': //'. $ host. $ script .'? '. $ Params;
Echo $ currenturl;
The dig php file and path host domain name query parameters are final. ...