note 30372 added to faq.html

From: Date: Sat, 15 Mar 2003 18:28:00 +0000
Subject: note 30372 added to faq.html
Groups: php.notes 
Request: Send a blank email to php-notes+get-45362@lists.php.net to get a copy of this message
I do not think you are right about not being able to specify something for the value attribute, but I can see where you would have thought it would fail: A fair warning about testing to see if a variable exists... when it comes to strings, the values '' and '0' are interpreted as false when tested this way... if ($string) { ... } //false for $string == ‘’ || $string == ‘0’ The best practice for testing to see if you received a variable from the form (which in the case of a checkbox, only happens when it is checked) is to test using this... if ( isSet($string) ) { ... } //true if and only if the variable is set The function tests to see if the variable has been set, regardless of its contents. By the way, if anyone's curious, when you do make a checkbox without specifying the value attribute, the value sent from the form for that checkbox becomes “on”. (That's for HTML in general, not PHP-specific). -- http://www.php.net/manual/en/faq.html.php http://master.php.net/manage/user-notes.php?action=edit+30372 http://master.php.net/manage/user-notes.php?action=delete+30372 http://master.php.net/manage/user-notes.php?action=reject+30372

« previous php.notes (#45362) next »