TP5 接收post数组报错:variable type error:array
in php with 0 comment

TP5 接收post数组报错:variable type error:array

in php with 0 comment

post参数

params.png

提交的时候出现500错误 提示:variable type error:array

解决方法

//error:variable type error:array
$this->request->post('option')
//改为
$this->request->post('option/a')

/x 来源

//think\Reuqest line:701
if (is_array($name)) {
    $this->param       = [];
    return $this->post = array_merge($this->post, $name);
}
return $this->input($this->post, $name, $default, $filter);

//think\Reuqest line:984
// 解析name
if (strpos($name, '/')) {
    list($name, $type) = explode('/', $name);
} else {
    $type = 's';
}
//line:1014 类型转换
if (isset($type) && $data !== $default) {
    // 强制类型转换
    $this->typeCast($data, $type); //typeCast就是类型转换函数
}

支持类型

/a 数组
/d 数字
/f 浮点
/b 布尔
/s 字符

Comments are closed.