某些版本的thinkphp没有request()->only(['user_id'=>0]);
只需要项目目录下的thinkphp/library/think/Request.php文件;
找到only方法,重新改写为即可
public function only($name, $type = 'param') { $param = self::$type(); if (is_string($name)) { $name = explode(',', $name); } $item = []; foreach ($name as $key => $val) { if (is_int($key)) { $default = null; $key = $val; } else { $default = $val; } if (isset($param[$key])) { $item[$key] = $param[$key]; } elseif (isset($default)) { $item[$key] = $default; } } return $item; }
标签:name,default,request,param,only,user,key,thinkphp From: https://www.cnblogs.com/zhangyouwu/p/18094800