File name contains offending content php gets the URL file name of the currently visited method summary

Source: Internet
Author: User
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.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.