when a form is submited,the item which is not set a value is given the value of "";
so you can not use isset($_POST["name"]) to determine if the item is set a value,
because the isset() can check if a variable is NULL( not "\0") or isset,
so you should use if($_POST["name"] != "") instead to get things done.
判断一个控件是否被赋值的时候,用isset()是不行的,因为isset
判断的依据是这个控件是不是NULL,而被POST的value,如果没被设置
那么它的值是"",而"" != NULL,所以应该用if($_POST["name"] != "")
来进行
toy example:
php -r '$var = ""; if(isset($var)){echo "\"\" != NULL\n";}'
阅读(1571) | 评论(1) | 转发(0) |