javascript - Get the form through file_get_content("php://input") in the background, how to parse the complete value with parameters
漂亮男人
漂亮男人 2017-05-31 10:34:53
0
2
765
<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?

漂亮男人
漂亮男人

reply all(2)
迷茫
$queryString = parse_url($url, PHP_URL_QUERY);
parse_str($queryString, $params);
var_dump($params);

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);

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!