Obtain the php code of the url address of the current page. Obtain the php code of the url address of the current page. The first is a method for obtaining a URL without parameters. The second is to obtain the complete URL function. if you are looking for the url parameter code. Obtain the url of the current page to obtain the url of the current page. php code: The first is to obtain a URL without parameters. The second is to obtain the complete URL function, if you are looking for the url parameter code.
Obtain the php Tutorial code of the url address of the current page. The first is to obtain the complete url function. if you are looking for the url parameter code.
// Description: obtain a url without parameters.
Function curpageurl ()
{
$ Pageurl = 'http ';
If ($ _ server ["https tutorial"] = "on ")
{
$ Pageurl. = "s ";
}
$ Pageurl. = "://";
If ($ _ server ["server_port"]! = "80 ")
{
$ Pageurl. = $ _ server ["server_name"]. ":". $ _ server ["server_port"]. $ _ server ['php _ self '];
}
Else
{
$ Pageurl. = $ _ server ["server_name"]. $ _ server ['php _ self '];
}
Return $ pageurl;
}
?>
Method 2
// Description: obtain the complete url
Function curpageurl ()
{
$ Pageurl = 'http ';
If ($ _ server ["https"] = "on ")
{
$ Pageurl. = "s ";
}
$ Pageurl. = "://";
If ($ _ server ["server_port"]! = "80 ")
{
$ Pageurl. = $ _ server ["server_name"]. ":". $ _ server ["server_port"]. $ _ server ["request_uri"];
}
Else
{
$ Pageurl. = $ _ server ["server_name"]. $ _ server ["request_uri"];
}
Return $ pageurl;
}
?>
In addition, $ _ server ['request _ url'] and $ _ server ['request _ url'] are slightly different:
$ _ Server ["request_uri"] returns the complete path (/directory/file. ext? Query = string)
$ _ Server ['request _ url'] returns only the file path, excluding parameters (/directory/file. ext), similar to $ _ server ['php _ self '], except that $ _ server ['request _ url'] is unavailable on some servers.
Bytes. Get the url of the current page...