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

前端 未结 12 714
北荒
北荒 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:32

    Following steps shows total information about how to get file, file with extension, file without extension. This technique is very helpful for me. Hope it will be helpful to you too.

      $url = 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_120x44dp.png';
            $file = file_get_contents($url); // to get file
            $name = basename($url); // to get file name
            $ext = pathinfo($url, PATHINFO_EXTENSION); // to get extension
            $name2 =pathinfo($url, PATHINFO_FILENAME); //file name without extension
    

提交回复
热议问题