改进Request类的input和post方法对json格式参数的接收

This commit is contained in:
thinkphp
2016-12-29 10:18:10 +08:00
parent e4c0e406cf
commit c4686695bc

View File

@@ -688,7 +688,7 @@ class Request
{
if (empty($this->post)) {
$content = $this->input;
if (empty($_POST) && strpos($content, '":')) {
if (empty($_POST) && 'json' == $this->type()) {
$this->post = (array) json_decode($content, true);
} else {
$this->post = $_POST;
@@ -713,7 +713,7 @@ class Request
{
if (is_null($this->put)) {
$content = $this->input;
if (strpos($content, '":')) {
if ('json' == $this->type()) {
$this->put = (array) json_decode($content, true);
} else {
parse_str($content, $this->put);