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

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

    An other way to get only the filename without querystring is by using parse_url and basename functions :

    $parts = parse_url("http://example.com/foo/bar/baz/file.php?a=b&c=d");
    $filename = basename($parts["path"]); // this will return 'file.php'
    

提交回复
热议问题