The following php code outputs on console "data error". The reason this happens is a known issue, but I'd like to get rid of the error messages.
<?php
gzuncompress("foo");
?>
I've searched on the web on how to suppress error messages on php and tried the following, with no success:
<?php
error_reporting(0);
ini_set("display_errors",0);
ob_start();
@gzuncompress("foo");
ob_end_clean();
?>
Thank you very much!
This is most likely that you have a custom error handler specified.
Reasoning:
The ob_start() / ob_end_clean() is a waste of time - this won't supress warning messages, only content you're pumping out through echos etc. So drop those two lines.
The error_reporting(0) should be enough - this says "turn off all errors". You won't get it in your error log or on screen. But a custom error handler will still be called.
The "display_errors "will stop it from going to screen, but it will appear in your log files.
The @ will also supress the message - essentially it sets "error_reporting(0)" temporarily. But the cusom error handler will still be called.
So the only thing that gets around all these is a custom error handler. That will still get called, even if you supress the error with @ or have error_reporting(0). The customer error handler should itself call error_reporting() and, if "0" should make sure it doesn't produce an error. It probably has it's own "hold the buffer, spit out my message then restore the buffer" code which is why it gets around the ob_start().
Only reaons I can think of: I've just ran your code above both through console and through webbrowser / apache and it's clean - no warning gets displayed etc, as you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With