PHP检查NULL [英] PHP Check for NULL

查看:74
本文介绍了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 ===运算符.

is_null($result['column'])

$result['column'] === NULL

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

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