PHP接收POST数据兼容form-data、x-www-form-urlencoded、application/json

1
2
3
4
5
6
7
8
9
10
11
$params = array();
foreach ($_POST as $key => $value) {
$params[$key] = $value;
}

if (empty($params)) {
$params_str = file_get_contents("php://input");
$params = json_decode($params_str, true);
}

ksort($params);

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :