duanque19820925 2011-10-21 16:17 采纳率: 0%
浏览 50
已采纳

从php中的url获取只有文件名而没有url中存在的任何变量值

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 only want to retrieve the learningphp.php from the url?

How to do this? Please help.

I used basename but it gives all the variable values also- learntolearn.php?lid=1348 which are in the url.

  • 写回答

10条回答 默认 最新

  • dongzheng4556 2011-10-21 16:34
    关注

    This should work:

    echo basename($_SERVER['REQUEST_URI'], '?' . $_SERVER['QUERY_STRING']);
    

    But beware of any malicious parts in your URL.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(9条)

报告相同问题?