Reputation: 805
I have one weird problem with error_reporting function.
I want to save current error_reporting level, disable error reporting for few lines, and restore it back. So I have following code:
$oldErrorReporting = error_reporting();
error_reporting(0);
//Some code, that will generate warning, or error, that I don't want to show
error_reporting(oldErrorReporting);
So, if I remove last line, there are no errors, and everything works fine. But if I add last line, I got error that happen in code while error reporting was turned off. So, is there any was to clear those errors that happen while error_reporting level was 0, and restore default error reporting level, without those errors that happen while error report was tuned off?
Upvotes: 0
Views: 633
Reputation: 173
What kind of code generates warnings? If it is a funciton try instead of lowering the debug level, to suppress the warning itself - write "@" in front of the function name
have a look at:
Suppress error with @ operator in PHP
Upvotes: 1
Reputation: 51817
maybe it's just a typo (if so, please don't rewrite code for a question, just copy&paste (and remove uneccesssary lines)), but you forgot the $
-sign in your last line:
error_reporting($oldErrorReporting);
Upvotes: 1