I'm designing an API with PHP and I'm wondering if there's a proper way of telling PHP not to ever write anything (not headers, or course not text,...) in the response by its own.
I mean, PHP usually returns the debug messages (errors, warnings, notices,...) directly in the response as HTML text, and if the API returns a JSON and an error (or something) occurs, this JSON would be corrupted by the PHP messages.
I have set error_reporting(0)
in production mode, but I don't know if this is enough to avoid PHP on ever responding something (and therefore corrupting the output), and I'm wondering if there is a more general way of telling PHP to write stuff into a log instead of sending it as an answer... Because ideally I don't want to set error_reporting
to 0, ideally I'd like to read the warnings / notices from a log file, not in the answer, as the client is not ready to handle it.