variable type error: array

当你在tp5框架中写方法时返回一个数组时,tp5会报错:variable type error: array

这是因为tp5不支持返回数组。

  1. 方法一:需要修改你的源代码

        直接在返回语句中加上json()、xml().....等你需要返回的数据类型函数

    例如:  

    return json($Data);

     

  2. 方法一:不修改修改源代码,需修改tp5配置文件

    找到并打开tp5框架中的"config.php"配置文件。在该配置文件中找到

    'default_return_type'    => 'html'(如下图所示)

    将这个属性设置为你需要返回的数据类型。例如这里可以设置为:

    'default_return_type'    => 'json'或者'default_return_type'    => 'xml'

 

 

文章来源:刘俊涛的博客

欢迎关注,有问题一起学习欢迎留言、评论

TP5报错variable type error: array的更多相关文章

  1. 解决FPDF报错:FPDF error: Not a JPEG file / FPDF error: Not a PNG file

    最近有个项目需要用到FPDF,但是输出的时候报错: FPDF error: Not a JPEG file: http://***/data/attachment/forum/201603/19/10 ...

  2. Heka 编译安装后 运行报错 panic: runtime error: cgo argument has Go pointer to Go pointer

    Heka 编译安装后 运行报错 panic: runtime error: cgo argument has Go pointer to Go pointer 解决办法: 1.  Start heka ...

  3. Echarts 报错:Uncaught Error: [MODULE_MISS]"echarts/config" is not exists!

    每天学习一点点 编程PDF电子书.视频教程免费下载:http://www.shitanlife.com/code   问题: 报错:Uncaught Error: [MODULE_MISS]" ...

  4. 更新Composer依赖报错处理Fatal error: Declaration of Fxp\Composer\AssetPlugin\Repository\AbstractAssetsRe

    更新Composer依赖报错处理 Fatal error: Declaration of Fxp\Composer\AssetPlugin\Repository\AbstractAssetsRe po ...

  5. mac系统中搭建apache+mysql+php的开发环境,安装mysql后,登录报错:mac ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

    php新手在mac系统中搭建apache+mysql+php的开发环境(按照这篇博客来操作的:http://my.oschina.net/joanfen/blog/171109?fromerr=xvC ...

  6. VS经常报错的link error 2019

    VS经常报错的link error 2019 原因如下: 可能是找得到头文件,但是相关的dll或者lib找不到,需要在配置里面添加相应的库文件. project=>configuration.. ...

  7. http报错之return error code:401 unauthorized

     http报错之return error code:401 unauthorized 依据HTTP返回码所表示的意思应该是未授权,没有输入账号和password,因此解决方法就直接在HTTP包里面 ...

  8. springboot 报错 Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported

    开始 controller 方法写的是 @RequestMapping( value = "/add", method = RequestMethod.POST ) public ...

  9. PHP编译安装报错:configure: error: mcrypt.h not found. Please reinstall libmcrypt

    我是在CentOS6.5安装php5.5.28这个版本,PHP编译代码如下: ./configure --prefix=/usr/local/php --with-config-file-path=/ ...

随机推荐

  1. Java Log Viewer日志查看器

    工欲善其事必先利其器 在投奔怒海--一个Domino老程序猿眼里的Java开发我提到眼下所做的Java开发中遇到的大量日志之问题. server控制台刷屏似地滚动,日志文件飞快地增长,debug的时候 ...

  2. C#编程(十)----------C#预处理器

    原文链接:http://blog.csdn.net/shanyongxu/article/details/46491757 C#中的预处理器指令 #IF 如果 C# 编译器遇到最后面跟有 #endif ...

  3. Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!

    执行Maven Install打包的时候,提示以下警告信息: [WARNING] Using platform encoding (GBK actually) to copy filtered res ...

  4. DWZ验证表单规则一览

    <form onsubmit="return validateCallback(this)" class="pageForm" action=" ...

  5. oracle转义符

    要使用_,则需要做如下转义 select column_name from user_tab_columns where table_name = 'SYS_TERMINAL_MAPPING' AND ...

  6. VC调用QT的UIDLL

    //VC程序#include "../QTDLL/ExportDll.h" int _tmain(int argc, _TCHAR* argv[]) { printf(" ...

  7. Python3.6学习笔记(六)

    WSGI Python Web Server Gateway Interface 规范学习 由于Python的灵活性,提供了多种方式可以作为服务端语言,包括Python编写的服务器(Medusa).P ...

  8. MySQL中的模糊查询和通配符转义

    MySQL中实现模糊查询有2种方式:一是用LIKE/NOT LIKE,二是用REGEXP/NOT REGEXP(或RLIKE/NOT RLIKE,它们是同义词). 第一种是标准的SQL模式匹配.它有2 ...

  9. data-stream-as-disjoint-intervals

    https://leetcode.com/problems/data-stream-as-disjoint-intervals/ /** * Definition for an interval. * ...

  10. 第十二章 springboot + mongodb(复杂查询)

    简单查询:使用自定义的XxxRepository接口即可.(见 第十一章 springboot + mongodb(简单查询)) 复杂查询:使用MongoTemplate以及一些查询条件构建类(Bas ...