//gets the current file namefunctionGetcururl () {if(!Empty($_server["Request_uri"])) { $scriptName=$_server["Request_uri"]; $nowurl=$scriptName; } Else { $scriptName=$_server["Php_self"]; if(Empty($_server["Query_string"])) { $nowurl=$scriptName; } Else { $nowurl=$scriptName."?".$_server["Query_string"]; } } return $nowurl;}$url=$HTTP _server_vars[' Request_uri '];Echo(Str_replace(‘/‘,‘‘,$url));$url=$_server[' Php_self '];$filename=substr($url,Strrpos($url, '/') +1 );Echo $filename;$url=$_server[' Php_self '];$arr=Explode( ‘/‘ ,$url );$filename=$arr[Count($arr)-1];Echo $filename;$url=$_server[' Php_self '];$filename=End(Explode(‘/‘,$url));Echo $filename;
//gets the URL address of the current filefunctionCurpageurl () {$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;}EchoCurpageurl ();
//description: Get the URL without parametersfunctionCurpageurll () {$pageURL= ' http '; if($_server["HTTPS"] = = "on") { $pageURL. = "S"; } $pageURL.= "://"; $this _page=$_server["Request_uri"]; //just take what's in front of you. if(Strpos($this _page, "?") !==false) $this _page=Reset(Explode("?",$this _page)); if($_server["Server_port"]! = "80") { $pageURL.=$_server["SERVER_NAME"]. ":" .$_server["Server_port"].$this _page; } Else { $pageURL.=$_server["SERVER_NAME"].$this _page; } return $pageURL;}EchoCurpageurll ();Echo' <br/> ';//description: Get the URL without parametersfunctioncurpageurlll () {$pageURL= ' http '; if($_server["HTTPS"] = = "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;}EchoCurpageurlll ();
//get domain name or host addressEcho $_server[' Http_host ']. ' <br/> ';#localhost//get web addressEcho $_server[' Php_self ']. " <br/> ";#/blog/testurl.php//Get URL parametersEcho $_server["Query_string"]. " <br/> ";#id=5//getting a user agentEcho $_server[' Http_referer ']. " <br/> ";//get the full URLEcho' http://'.$_server[' Http_host '].$_server[' Request_uri ']. " <br/> ";Echo' http://'.$_server[' Http_host '].$_server[' php_self ']. '? '.$_server[' Query_string ']. " <br/> ";#http://localhost/blog/testurl.php?id=5//full URL with port numberEcho' http://'.$_server[' server_name ']. ': '.$_server["Server_port"].$_server["Request_uri"]. " <br/> ";#http://localhost:80/blog/testurl.php?id=5//only take path$url= ' http://'.$_server[' server_name '].$_server["Request_uri"];Echo dirname($url);
Gets the file name of the current file and gets the URL routing address to go to the current file