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’
Similar Posts:
- [Solved] Fatal error: Call to undefined function json_decode()
- TypeError: Object of type ‘int32’ is not JSON serializable
- How to Solve Vue Space Line Wrap Error
- Solve the problem of “resource interpreted as document but transferred with MIME type application / JSON” in IE browser
- TypeError: Object of type ‘datetime‘ is not JSON serializable [Solved]
- Tensorflow error due to uninitialized variable [How to Fix]
- Postman reported an error unsupported media type [How to Solve]
- Uncaught Error: _registerComponent(…): Target container is not a DOM element
- Invalid prop: type check failed for prop value
- [Solved] Lazy loading NSBundle MobileCoreServices.framework…