ThinkPHP5错误解析之variable type error:array
来源:互联网 发布:尊龙长相知乎 编辑:程序博客网 时间:2024/05/21 19:24
在TP5的post提交方式中,有一个坑爹的bug就是post提交数据不能提交数组。
请注意是不能提交数组形式的数据,而不是单纯的数据。举个例子:注意以下2种格式数据的比较:
第一种:普通的数据提交,这种格式的数据在TP5中用post提交,$request->post(‘参数’);可以接受数据。
//js,{ 'data':123, 'id':1, 'name':'user'}
下面看坑爹的第二种:
{'data':[1,2,3,4,5],'id':1,'name':'user'}
这种形式的数据同过POST提交数据在TP5框架内通过$request->post(‘参数’);去接收就会报错。
variable type error:array
这是因为tp5不能用post去接收数组‘data’:[1,2,3,4,5]这种数据。在通过request的post方法取获取时,post方法不能分辨它是否是数组。
所以在想不改变post提交方式的情况下,解决办法之一就是用/a。(这里的/a就相当于告诉解析器我要获取一个数组。)
将原来的接收方式参数修改为:
Request::instance()->post('参数/a');
比如在本文的例子中就可以修改为:$request->post(‘data/a’):
0 0
- ThinkPHP5错误解析之variable type error:array
- ThinkPHP5错误解析之variable type error:array
- ThinkPHP5请求参数为数组时报错:variable type error:array
- PHP day9 TP post接受数据 variable type error:array
- TP5接收数组报错variable type error:array
- error: variable '__this_module' has initializer but incomplete type错误解决
- error: variable '__this_module' has initializer but incomplete type错误解决
- thinkphp5错误:类型错误: Argument 1 passed to think\Hook::import() must be of the type array
- Box2D: 错误variable length array of non-POD element type 'b2Vec2'
- Box2D: 错误variable length array of non-POD element type 'b2Vec2'
- procob handle array-type host variable
- 关于错误: error: variable ‘QApplication app’ has initializer but incomplete type
- Android之ndk编译出现这个错误error: unused variable 'a' [-Werror=unused-variable]
- error: array type has incomplete element type
- PHP Fatal error: Cannot use object of type stdClass as array in错误
- php错误 Fatal error: Cannot use object of type stdClass as array in……
- qt error: variable `QPainter painter' has initializer but incomplete type
- Error: variable 'QApplication app' has initializer but incomplete type
- 使用D3制作统计图表、线性图表、水平柱状图表、饼图 -- (五)饼状图表
- 用java写系统画图板
- OC和Swift混编
- Android--常见错误整理
- 进阶之初探nodeJS
- ThinkPHP5错误解析之variable type error:array
- BZOJ4817: [Sdoi2017]树点涂色
- C语言中函数的数据传递
- 清除wnTKYg 这个挖矿工木马的过程讲述
- OS进程
- 第十五届北京师范大学程序设计竞赛决赛 C. Captcha Cracker【水题、模拟】
- LinkMap分析
- Javascript中的async await
- 将排序数组转换为高度最小的二叉搜索树