note 53926 added to types.comparisons
| From: | tom at osu1 dot php dot net | Date: | Fri, 17 Jun 2005 09:27:52 +0000 |
| Subject: | note 53926 added to types.comparisons | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-90575@lists.php.net to get a copy of this message | ||
<?php
if (strlen($_POST['var']) > 0)
{
// form value is ok
}
?>
When working with HTML forms this a good way to:
(A) let "0" post values through like select or radio values that correspond to array keys
or checkbox booleans that would return FALSE with empty(), and;
(B) screen out $x = "" values, that would return TRUE with isset()!
Because HTML forms post values as strings, this is a good way to test variables!
----
Manual Page -- http://www.php.net/manual/en/types.comparisons.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+53926
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53926&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53926&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53926&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53926&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+53926&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53926&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+53926&report=yes
Search -- http://master.php.net/manage/user-notes.php