Question

I'm using CodeIgniter and I've added the following lines into my index.php:

error_reporting(E_ALL ^ E_NOTICE); 
ini_set('display_errors', 0);
ini_set('log_errors', 1);
ini_set('error_log', $_SERVER['DOCUMENT_ROOT'] . '/php_errors.log');

For some reason, however, PHP is always displaying Warnings/Errors anyway, and not creating a log into the writable directory. I know the above code is being hit because if I remove the "^ E_NOTICES" part and resubmit, I will see tons of notices. I also threw a die() statement after the above code to verify it was being hit. Lastly, I grepped by entire codebase to verify that "display_errors" isn't used later in the code, overwriting my value of 0.

Is there something else I could be missing that prevents me from stopping the display of errors?

Was it helpful?

Solution

You should search for "set_error_handler" in the CodeIgniter source. It looks like their error handler respects the error_reporting setting but not the display_errors setting, a common mistake. See also: Does a custom PHP error handler respect PHP configuration?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top