<form>
<input type="text" name="goods_name" value="西瓜500g">
<input type="text" name="origin_url" value="https://www.baidu.com?page=50&since=2015">
<input type="text" name="price" value="10.0">
</form>
The backend is received through file_get_content("php://input"). How to parse the complete three values of goods_name, origin_url, and price?
There is a solution on the Internet that uses ‘&’ as the node to cut through explode, but if you do this, the origin_url will get
“https://www.baidu.com?page=50”
There is also an extra since field instead of the complete
“https://www.baidu.com?page=50&since=2015”
Does anyone know of any method that can completely parse the url value with parameters?
Thank you for pointing it out. I haven’t used these two functions for a long time. I forgot that
parse_str
directly receives the return value in the parameter = =Thank you very much, the source code is like this,
$packData=urldecode(file_get_contents( "php://input" ));
parse_str($packData,$params);//The parse_str function has no return value, so $params = parse_str($queryString); is the wrong way to write it
//var_dump($param);