How do I turn off PHP Notices?

user198729 picture user198729 · May 19, 2010 · Viewed 451.7k times · Source
Notice: Constant DIR_FS_CATALOG already defined

I've already commented out display_errors in php.ini, but is not working.

How do I make PHP to not output such things to browsers?

UPDATE

I put display_errors = Off there but it's still reporting such notices,

Is this an issue with PHP 5.3?

Reporting numerous Call Stack too..

Answer

Cristian picture Cristian · May 19, 2010

From the PHP documentation (error_reporting):

<?php
// Turn off all error reporting
error_reporting(0);
?>

Other interesting options for that function:

<?php

// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);

// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

// Report all errors except E_NOTICE
// This is the default value set in php.ini
error_reporting(E_ALL & ~E_NOTICE);
// For PHP < 5.3 use: E_ALL ^ E_NOTICE

// Report all PHP errors (see changelog)
error_reporting(E_ALL);

// Report all PHP errors
error_reporting(-1);

// Same as error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);

?>