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

Reply via email to