Currently I disabled the error messages via UI under Administration > Developement > Logging & Errors:


But I want to be able to do this via the settings.php file. How can that be done?


And the Drupal way:

Add this line in settings.php

$conf['error_level'] = 0; // 0: None, 1: Errors and warnings, 2: All messages

You can set any persistent variable this way. You can get the variable names simply using Firebug or any browser's developer tool and check the name attribute of the input field in the administration form. Which in you case the Logging & Errors page. If you look at the source code, the radio buttons have the name attribute error_level and each radio button has a value attribute. Simply set this value to the variable in you settings.php using $conf array.

You can also set any variable using variable_set() function in any custom module, in an update script for example.

Or using Drush:

drush vset error_level 0
| improve this answer | |
  • I set the error_level to: 1 (errors & warnings) ... and those strict errors arent showing now even after a clear cache. But now the question is what does "errors & warnings" encompass? I dont want to supress other errors that i might want to know about. – Patoshi パトシ Sep 25 '14 at 21:46
  • If I look at the code of error_displayable() function, I see that if you set it to 1, it will display only the errors whose types are NOT 'Notice' AND NOT 'Strict warning'. – Елин Й. Sep 26 '14 at 14:57

You can use this code on your settings.php file.

error_reporting(E_ALL ^ E_STRICT);


error_reporting(E_ALL & ~E_STRICT);

Note: E_STRICT has only been part of E_ALL since php 5.4


| improve this answer | |

Check if adding the following at the begging of the settings.php works:

ini_set('error_reporting', 30711);

that will affect the PHP settings for your site.

| improve this answer | |
  • does that only disable the "strict errors" and nothing else? Where did you find that 30711 code? thanks. – Patoshi パトシ Sep 25 '14 at 3:35
  • In PHP, all the predefined constants from that are for error handling have a numeric value assigned. You can find more info at: stackoverflow.com/questions/3758418/… – gerzenstl Sep 25 '14 at 13:20

Drupal seems to override the setting.php

The best answers I found so far are the ones in that thread: Remove the strict warnings from being shown

Either you go hide the warnings in drupal interface:
This will hide everything, but occuring problems will still be logged, and hiding might be a good solution for a production environment anyway.

Or you directly modify the Drupal error handler:
This is the solution I chose, which is more focused on the need. The only drawback I see is that the operation might have to be done again when updating drupal version.

btw, avoid using lines like ini_set('error_reporting', 30711);
error and warning values use mask for readibility, so, you'd better use something like (E_ALL & ~E_STRICT & ~E_WARNING) than any crude number value

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.