免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 987 | 回复: 0

php check if an POST item is given a value [复制链接]

论坛徽章:
0
发表于 2011-12-20 09:48 |显示全部楼层
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";}'

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP