Re: Type of form element

From: Date: Mon, 31 Oct 2005 16:33:22 +0000
Subject: Re: Type of form element
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-224885@lists.php.net to get a copy of this message
On 31 Oct 2005, at 14:54, Chris Shiflett wrote:
Hopefully it is also clear that your argument revolves around the idea that PHP would create $_POST['foo'] as NULL if the checkbox is not checked. This is wrong for two reasons:
No, no, that's not what I said - I wouldn't contemplate such silliness! The thing I was wrong on is that PHP converts unset parameters (as opposed to nonexistent ones which it obviously can't do anything about) to an empty string, e.g. given ?a=&b=1, $_REQUEST['a'] is "", not NULL. However, it still serves to underline my other point that using isset without actually knowing that is a potentially dangerous thing. Getting into the habit of using it for looking in the likes of $_REQUEST means you're likely to use it other places where you have no such guarantee, and you'll have a bug to track down. Using array_key_exists means you will never be exposed to this possibility, no matter where your data comes from. Marcus -- Marcus Bointon Synchromedia Limited: Putting you in the picture marcus@synchromedia.co.uk | http://www.synchromedia.co.uk

« previous php.general (#224885) next »