Re: [PHP] disable "notice" errors

2003-08-29 Thread Ernest E Vogelsinger
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/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] disable "notice" errors

2003-08-29 Thread Pete James
You have two solutions, one of which is better.

A. Fix the problem, and define your indexes.
B. Set error_reporting  =  E_ALL & ~E_NOTICE
I'd strongly recommend doing A before B, as PHP doesn't carp for the 
sake of carping.

fatih olcer wrote:
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"..
RH9,PHP4
thanks for help.
fatih.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] disable "notice" errors

2003-08-29 Thread fatih olcer
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"..

RH9,PHP4
thanks for help.

fatih.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php