Nathan Taylor wrote:

Hey guys,

I was checking over one of my sites the other day trying to weed out the elusive notices that E_ALL turned up and I got some notices that I'm not too sure how to handle.

I know how to handle most of these errors however the ones that are snagging me up are the "Notice: Undefined index: _blah_ in _blah_." Most of these are array indices in super globals such a $_GET, $_SESSION, etc. How can I get rid of these little buggers?

The notice is basically saying that you are trying to assign a value to a variable for an index that doesn't exist (so the value of the variable can't be guaranteed).


One way is to verify that the index exists before you assign its value to a variable. This is my favorite way :

$var = isset($_POST['key']) ? $_POST['key'] : NULL;

You might also want to check out extract() -- which does the same thing.

By the way -- pat yourself on the back for going with error_reporting(E_ALL). Its one of the first steps towards effective programming. :)

--
Burhan Khalid
phplist[at]meidomus[dot]com
http://www.meidomus.com

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



Reply via email to