+
81
-

回答

/**
* 获取 post 参数; 在 content_type 为 application/json 时,自动解析 json
* @return array
*/
private function initPostData()
{
if (empty($_POST) && false !== strpos($this->contentType(), 'application/json')) {
$content = file_get_contents('php://input');
$post = (array)json_decode($content, true);
} else {
$post = $_POST;
}
return $post;
}

网友回复

我知道答案,我要回答