PHP 点滴疑惑

  1. 在数据库中,字段为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']));
    ?>

     

 

posted @ 2016-01-11 14:45  五毛钱的饼  阅读(103)  评论(0编辑  收藏  举报