Get only filename from url in php without any variable values which exist in the url

前端 未结 12 729
北荒
北荒 2020-12-05 12:41

I want to get filename without any $_GET variable values from a URL in php?

My URL is http://learner.com/learningphp.php?lid=1348

I

12条回答
  •  广开言路
    2020-12-05 13:19

    Use this function:

    function getScriptName()
    {
        $filename = baseName($_SERVER['REQUEST_URI']);
        $ipos = strpos($filename, "?");
        if ( !($ipos === false) )   $filename = substr($filename, 0, $ipos);
        return $filename;
    }
    

提交回复
热议问题