How to get parameters from a URL string?

前端 未结 13 1450
孤城傲影
孤城傲影 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:43
    $web_url = 'http://www.writephponline.com?name=shubham&email=singh@gmail.com';
    $query = parse_url($web_url, PHP_URL_QUERY);
    parse_str($query, $queryArray);
    
    echo "Name: " . $queryArray['name'];  // Result: shubham
    echo "EMail: " . $queryArray['email']; // Result:singh@gmail.com
    
    0 讨论(0)
提交回复
热议问题