ThinkPHP5错误解析之variable type error:array

这种形式的数据同过POST提交数据在TP5框架内通过$request->post(‘参数’);去接收就会报错。

variable type error:array 这是因为tp5不能用post去接收数组‘data’:[1,2,3,4,5]这种数据。

在通过request的post方法取获取时,post方法不能分辨它是否是数组。

所以在想不改变post提交方式的情况下,解决办法之一就是用/a。(这里的/a就相当于告诉解析器我要获取一个数组。)

$data = $this->request->post("data/a");

  

posted @ 2022-09-21 10:22  路三千  阅读(1667)  评论(0)    收藏  举报