TP5.0 里面不知道算不算是bug的问题

浏览:187 发布日期:2020/08/13 分类:ThinkPHP5专区 关键字: bug TP5.0 request
在做接口开发时,大家常用的参数获取方式有 input,param,post,get,request等方法,目前发现request()获取参数时,前端用json字符串提交的参数无法获取到,而用post或者get能正常获取如有需要,可以将/thinkphp/library/think/Request.php 中修改request()方法public function request($name = '', $default = null, $filter = '')
    {
        if (empty($this->request)) {
            $content = $this->input;
            if(empty($_REQUEST)){
                if(false !== strpos($this->contentType(), 'application/json')){
                    $this->request = (array) json_decode($content, true);
                }
            }else {
                $this->request = $_REQUEST;
            }
        }
        if (is_array($name)) {
            $this->param          = [];
            $this->mergeParam     = false;
            return $this->request = array_merge($this->request, $name);
        }
        return $this->input($this->request, $name, $default, $filter);
    }
最佳答案
评论( 相关
后面还有条评论,点击查看>>