How to get response as json format(application/json) in yii?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
In the controller action that you want to render JSON data, e.g: actionJson()
See more Yii API
For Yii2 inside a controller:
I think this solution is not the best way to end application flow, because it uses PHP's
exit()
function, witch means immediate exit from execution flow. Yes, there is Yii'sonEndRequest
handler, and PHP'sregister_shutdown_function
but it still remains too fatalistic.For me the better way is this
So, the application flow continues to execute even after.