PHP 检查 NULL [英] PHP Check for NULL

查看:29
本文介绍了PHP 检查 NULL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码如下:

$query = mysql_query("SELECT * FROM tablex");

if ($result = mysql_fetch_array($query)){

    if ($result['column'] == NULL) { print "<input type='checkbox' />"; }
    else { print "<input type='checkbox' checked />"; }
}

如果值是 NOT NULL 我仍然得到未选中的框.我从上面做错了什么,应该 $result['column'] == NULL 工作吗?

If the values are NOT NULL i still get the uncheked box. Am i doing something wrong from above, shoudnt $result['column'] == NULL work?

有什么想法吗?

推荐答案

使用 is_null=== 运算符.

Use is_null or === operator.

is_null($result['column'])

$result['column'] === NULL

这篇关于PHP 检查 NULL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆