Drupal: .htaccess Access Deny
August 21, 2014 – 7:59 am | No Comment

In this article I will tell how to forbid access to certain resources for some clients. The instructions will include descriptions of different directives.

Read the full story »
CSS Templates

Contain reviews and news about CSS Templates.

Freebies

Contain freebies such as icons, graphics, headers and images for your websites.

Fun Stuff

Contains other fun stuff for entertainment or interesting site showcase.

How-To

Contain technical elaborations on some specific workarounds or common tweak.

Joomla Templates

Contains reviews and news about Joomla templates.

Home » How-To

Drupal: How to Hide PHP Notifications

Submitted by on July 19, 2011 – 8:30 amOne Comment

PHP notifications we’ll deal with are error notices and warnings which appear in a user’s browser. A user could see system paths in these messages. So I strongly recommend you to hide PHP notifications on your site’s pages. In this article, I would tell how you can do this.

Please keep in mind that you can always find these notifications in Drupal logs if required.

Solutions:

Hide PHP notifications on error Reporting page

  1. Open “Error reporting” page:
    • Drupal 6: admin/settings/error-reporting
    • Drupal 5: admin/settings/error-reporting
  2. Set “Error reporting” parameter at the bottom of the page to “Record errors to the system log”. Thus, errors will be logged and user won’t see them.

Disable showing of warnings in php.ini

You can disable showing of errors in php.ini (this is PHP configuration file). To do this, find error_reporting parameter in php.ini:

error_reporting = E_NONE

Disable showing of notifications in .htaccess

You can change showing of errors on  a remote server that maintains .htaccess. TO do this, add the following line to .htaccess in the root of a site:

php_value error_reporting E_NONE

One more option:

php_flag display_errors off
php_flag display_startup_errors off

Disable error reporting in the code of PHP-scripts

Other way you can disable error reporting with is to add the following code:

error_reporting(0);

in /index.php file before this line:

require_once ‘./includes/bootstrap.inc';

Good luck!

One Comment »

  • beanluc says:

    “Don’t Hack Core” is a *fundamental* rule. I’m surprised you’re indicating a core hack to solve this trivial problem.

    http://drupal.org/best-practices/do-not-hack-core

    Especially after you just finished providing four other ways, including one way which is a site setting available in the administrator pages.

    Good post, thank you, I’mna bookmark it to show others in the future, but, kids, please, Don’t Hack Core – it’s *really* not worth it, and, in this case, as in almost all cases, completely un-necessary.

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.