doumianfeng6979 2013-05-16 17:04
浏览 483
已采纳

如何获取URL的查询字符串(问号后面的部分)?

How can I get only the content from a query string staring from ?:

asegment?param1=value1&param2=value2

NOTE: I only need all the content after the "?", also I want to ommit that character.

  • 写回答

6条回答 默认 最新

  • dougehe2022 2013-05-16 17:06
    关注

    Here is the Regex \?(.+), and a Rubular to prove it. And to use it:

    preg_match("/\?(.+)/", $inputString, $matches);
    if (!$matches) {
        // no matches
    }
    
    $result = $matches[1];
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?