thinkphp 有时会出现variable type error: array 错误
修改该异常方法,将是数组的返回进行json_encode
获得$content的下一行增加下面一行:
if(is_array($content)) $content = json_encode($content);
/**
* 获取输出数据
* @access public
* @return mixed
*/
public function getContent()
{
if (null == $this->content) {
$content = $this->output($this->data);
if(is_array($content)) $content = json_encode($content);
if (null !== $content && !is_string($content) && !is_numeric($content) && !is_callable([
$content,
'__toString',
])
) {
throw new \InvalidArgumentException(sprintf('variable type error: %s', gettype($content)));
}
$this->content = (string) $content;
}
return $this->content;
}