Scenario:
Ajax calls to a PHP script. An answer is always expected in JSON Format.
Problem:
In some cases ( Exception, Error, etc.) no Json is returned but simple plain text.
Question:
How can I force PHP to always return JSON no matter what? But not turning all errors and warnings off?
I think about something like:
- set_error_handler
- set_exception_handler
How can I force some bad errors like parse errors to output JSON format?