The file name contains illegal content. Summary of the method of obtaining the currently accessed URL file name in PHP.

WBOY
Release: 2016-07-29 08:41:48
Original
754 people have browsed it

Recommended functions:
First, PHP gets the URL of the current page: dedecms also uses this

Copy the 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 the code The code is as follows:


$url=$HTTP_SERVER_VARS['REQUEST_URI'];
e cho(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 3:

Copy the code The code is as follows:


$url = $_SERVER['PHP_SELF'];
$arr = explode( '/' , $url );
$filename= $arr[count($arr)-1];
echo $filename;
?>


Method 4:

Copy the code The code is as follows:


$url = $_SERVER['PHP_SELF'];
$filename = end( explode('/',$url));
echo $filename;
?>

The above has introduced a summary of the method of obtaining the currently accessed URL file name in PHP if the file name contains illegal content, including the content of the file name containing illegal content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template