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