Tag Archives: TP5

TP5 variable type error: array [How to Solve]

variable type error: array

When you return an array when you write a method in the TP5 framework, TP5 will report an error: variable type error: array

This is because TP5 does not support returning arrays

method 1: you need to modify your source code

Directly add JSON(), XML()… And other data type functions you need to return

to the return statement, for example:

return json($Data);

method 1: do not modify the source code, but modify the TP5 configuration file

Locate and open the “config. PHP” configuration file in the TP5 framework. Find

‘default in the configuration file_return_type’    => ‘ HTML ‘(as shown in the figure below)

set this attribute to the data type you need to return. For example, it can be set as:

‘default_return_type’    => ‘ JSON ‘or’ default_return_type’    => ‘ xml’