PHP 点滴疑惑
- 在数据库中,字段为NULL,可以使用empty()进行判断
<?php $CONFIG['hostname'] = 'localhost'; $CONFIG['username'] = 'root'; $CONFIG['password'] = ''; $CONFIG['database'] = 'test'; $link = mysql_connect("localhost", $CONFIG['username'], $CONFIG['password']); mysql_select_db($CONFIG['database'], $link ); $charset = mysql_query("SET NAMES 'utf8'", $link); $sql = "select init_weight from mytableas where id=3948"; $query = mysql_query($sql); var_dump(mysql_fetch_assoc($query)); $init_weight = mysql_fetch_assoc($query); var_dump(empty($init_weight['init_weight'])); ?>