Php to get the code summary of the currently accessed file name. you can select as needed. Recommended functions:
First, PHP obtains the URL of the current page: dedecms also uses this
The code is as follows:
// Obtain 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:
The code is as follows:
$ Url = $ HTTP_SERVER_VARS ['request _ URI '];
Echo (str_replace ('/', '', $ url ));
?>
Method 2:
The code is as follows:
$ Url = $ _ SERVER ['php _ SELF '];
$ Filename = substr ($ url, strrpos ($ url, '/') + 1 );
Echo $ filename;
?>
Method 3:
The code is as follows:
$ Url = $ _ SERVER ['php _ SELF '];
$ Arr = explode ('/', $ url );
$ Filename = $ arr [count ($ arr)-1];
Echo $ filename;
?>
Method 4:
The code is as follows:
$ Url = $ _ SERVER ['php _ SELF '];
$ Filename = end (explode ('/', $ url ));
Echo $ filename;
?>