Tom Rawson wrote:
I have many places where I use references like this:

        if ($fields['flags']['someflag']) ...

or perhaps

        if ($_POST['checkboxfieldname']) ...

If there is no value for 'someflag', or if the check box was not checked -- both of which are often the case -- these generate errors at level E_NOTICE. Is there any way to prevent references to missing array elements from generating errors without turning off all E_NOTICE notifications?

the answer is to write code that doesn't produce notices. which means checking the vars (array items) exist before using them.

use of isset() may help you - isset() shouldn't give a notice if you
are checking for an item in an array and it doesn't exist - I say "shouldn't"
because I half remember reading about someone having that very problem,
I can't remember whether it was bogus or a bug in their version of php.

a cousin of isset() is empty() which is not a function as I undertstand it
but a language construct, and will also be of help here I think.


Thanks,

--
Tom


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



Reply via email to