Re: disable "notice" errors

From: Date: Fri, 29 Aug 2003 19:22:04 +0000
Subject: Re: disable "notice" errors
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-161189@lists.php.net to get a copy of this message
At 20:56 29.08.2002, fatih olcer said: --------------------[snip]-------------------- >how to disable "notice error" output > > >i have set "error_reporting = 2039" (in PHP.ini); >but it doesnt work.i still get "notice :Undefined index".. --------------------[snip]-------------------- as a third method, you can explicitly disable warnings and errors for a single command using the '@' modifier. This is widely unknown but a very handy feature: having excessive error_reporting turned on [error_reporting(E_ALL)] helps a lot in spotting down possible problems in your code, but again there are numerous locations where e.g. array keys might be there, or not. You could either use array_key_exists(), or the @ modifier to suppress the warning. Example: // this will raise a warning $test = $array['nonexisting_key']; // this avoids array access if the key is not set, // OTOH the receiving variable might be undefined if (array_key_exists('nonexisting_key', $array)) $test = $array['nonexisting_key']; // this is a simple, elegant, and even self-documenting solution $test = @$array['nonexisting_key']; -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/

« previous php.general (#161189) next »