If you’re like me, stuck with 3 years old, unmaintained code that has to run on newer PHP version, you’re bound to receive some warning and error messages along the way. The correct way when facing situation like this is to find out what is causing these messages, and fix them.

Well, perhaps

To set it globally on any site on the server that uses PHP, you can set itu on php.ini file. Find out which php.ini your php install use, usually it’s on /etc/php.ini. If you use some kind of death contraption such as  cpanel, do this

[surfer@www ~]$ sudo php -i | grep php.ini
[sudo] password for surfer:
Configuration File (php.ini) Path => /usr/local/lib
Loaded Configuration File => /usr/local/lib/php.ini

As you can see, my cpanel easyapache 3 install stores php.ini in /usr/local/lib. Fine, I’ll use that

Open it with your favorite text editor, and find the line “display_errors”, and set it to “off” or “0”

display_errors = Off

Restart Apache,

To check whether this setting is active or in effect, create a php page, containing:


Open the web page from your web browser, scroll down to the “Core” section, and look for “display_errors”

coreThose pesky warning should go away.

…..Unless you’re using CodeIgniter. The chaps at CodeIgniter decide not to respect php.ini and instead put the flag on their index.php file. Hence,  to suppress the warning and error messages on CodeIgniter, open index.php with a text editor, and find this line


If you want to skip warning and notices but keep the error messages, change it to


And to turn it off completely, change it to


…And we’re done 🙂

By ikhsan

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.