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

post参数

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

解决方法

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

/x 来源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//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 字符


评论区