I'm pretty sure you can rely on the fact that they are undefined if not
checked.. It's somewhere in the HTML or HTTP standard.. Also, the manual
page of empty() says it won't generate errors if the variable isn't set.. So
empty() is probably the best way to go then..

-- 
// DvDmanDT
MSN: dvdmandt€hotmail.com
Mail: dvdmandt€telia.com
<[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
> On 26 Jan 2005 Jason Barnett wrote:
>
> > if (isset($_POST['checkboxfieldname'])) {
> >    /** do stuff */
> > }
>
> Sorry, I should have mentioned that I knew about using isset -- it
> works OK for the checkbox example, though I'm not clear if this
> behavior is specified and therefore will not change -- i.e. can one
> rely on the fact that the checkbox field name is missing entirely from
> _POST if the box is not checked?  Or are there cases where it could be
> present but with an empty or NULL value?
>
> If one must check the value and not just the existence of the checkbox
> entry, or for other uses, e.g. where a flag may or may not be present,
> one is saddled with clumsy constructs like:
>
> if (($isset($array['index']) && ($array['index'] == 1)) ...
>
> I would prefer that the second expression return FALSE, or that
> $array['index'] where the index is not present simply return NULL -- or
> probably better, an option to avoid E_NOTICE level errors for such
> cases.
>
> --
> Tom

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

Reply via email to