Recommended functions:
First, PHP gets the URL of the current page: Dedecms is also used for this
Copy the Code code 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 One:
Copy the Code code as follows:
$url = $HTTP _server_vars[' Request_uri ');
Echo (Str_replace ('/', ', $url));
?>
Method Two:
Copy the Code code as follows:
$url = $_server[' php_self ');
$filename = substr ($url, Strrpos ($url, '/') +1);
echo $filename;
?>
Method Three:
Copy the Code code as follows:
$url = $_server[' php_self ');
$arr = explode ('/', $url);
$filename = $arr [Count ($arr)-1];
echo $filename;
?>
Method Four:
Copy the Code code as follows:
$url = $_server[' php_self ');
$filename = End (Explode ('/', $url));
echo $filename;
?>
The above describes the file name contains the offending content PHP gets the current access URL file name of the method summary, including the file name contains the content of the offending content, I hope that the PHP tutorial interested in a friend helpful.