PHP - error_get_last method for warnings?

Use error_reporting(0) to not show the warning or any errors in the rendered page. It will still show up in your server error logs and you can still use error_get_last() to get the last error.

You can test it out with this:

error_reporting(0);
unlink('some file that does not exist'); // generates a warning
print_r(error_get_last());

EDITED: Please note that error_reporting(0) will affect subsequent code, so you'll want to set it back to the level you want after you're through the code where you want to suppress the error display.

Tags:

Php