How to get parameters from a URL string?

前端 未结 13 1481
孤城傲影
孤城傲影 2020-11-22 04:05

I have a HTML form field $_POST[\"url\"] having some URL strings as the value. Example values are:

https://example.com/test/1234?email=xyz@test.com
         


        
13条回答
  •  灰色年华
    2020-11-22 04:42

    You can use the parse_url() and parse_str() for that.

    $parts = parse_url($url);
    parse_str($parts['query'], $query);
    echo $query['email'];
    

    If you want to get the $url dynamically with PHP, take a look at this question:

    Get the full URL in PHP

提交回复
热议问题