Re: Avoiding NOTICEs on Array References

From: Date: Wed, 26 Jan 2005 21:57:38 +0000
Subject: Re: Avoiding NOTICEs on Array References
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-207431@lists.php.net to get a copy of this message
trlists@clayst.com wrote:
On 26 Jan 2005 Jennifer Goodie wrote:
if (isset($fields['flags']['someflag']) && $fields['flags']['someflag']) if (isset($_POST['checkboxfieldname']) && $_POST['checkboxfieldname']) The && short-circuits, so the second part of the conditional only gets evaluated if the first part is true.
I know I can use isset, it just adds a bunch of extra code. I like to find minimal solutions to these things if possible as they are easier to read, and faster to execute. -- Tom
As already suggested, isset() and empty() are good choices here. Which one you choose it dependent on what exactly your truth table is. Or, it might work better for you to use !isset() or even !empty(). if (!empty($_POST['checkboxfieldname']) { /** do stuff */ } -- Teach a man to fish... NEW? | http://www.catb.org/~esr/faqs/smart-questions.html STFA | http://marc.theaimsgroup.com/?l=php-general&w=2 STFM | http://www.php.net/manual/en/index.php STFW | http://www.google.com/search?q=php LAZY | http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins

« previous php.general (#207431) next »