Recommended functions:
First, PHP gets the URL of the current page: dedecms also uses this
Copy code The code is as follows:
//Get the current script URL
function GetCurUrl()
{
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;
}
Method 1:
Copy code The code is as follows:
$url=$HTTP_SERVER_VARS['REQUEST_URI'];
echo(str_replace('/','', $url));
?>
Method 2:
Copy the code The code is as follows:
$url = $_SERVER['PHP_SELF'];
$filename= substr( $url , strrpos($url , '/')+1 );
echo $filename;
?>
Method three:
Copy code The code is as follows:
$url = $_SERVER['PHP_SELF'];
$arr = explode( '/' , $url );
$filename= $arr[count($ arr)-1];
echo $filename;
?>
Method 4:
Copy code The code is as follows:
$url = $_SERVER['PHP_SELF'];
$filename = end(explode('/',$url));
echo $filename;
?>
http://www.bkjia.com/PHPjc/321142.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321142.htmlTechArticleRecommended functions: First, PHP gets the URL of the current page: dedecms also uses this copy code. The code is as follows: // Get the current script URL function GetCurUrl() { if(!empty($_SERVER["R...