PHP比较

  1. PHP函数比较

    PHP函数比较

  2. PHP数据比较

    PHP数据比较

  3. 易错速记

    <?php
    //易错1
    $a = null;
    var_dump(isset($a));      //false
    $b = "0";
    var_dump(empty($b));      //true
    
    //易错2
    var_dump(0 == '0');             //true
    var_dump(0 == '');              //true
    var_dump(0 == null);            //true
    var_dump(0 == []);              //false
    var_dump('0' == '');            //false
    var_dump('0' == null);          //false
    var_dump('0' == []);            //false
    var_dump('' == []);             //false
    var_dump('' == null);           //true
    var_dump([] == null);           //true
    //0     不等于空数组
    //'0'   只等于0
    //''    只等于0和null
    //[]    只等于null
    //null  不等于'0'
    
    //false 全等于
    //true  全不等
    
  4. PHP8字符串、数字比较优化

    <?php
    # PHP < 8.0.0
    var_dump(0 == 'abc'); //true
    # PHP ^ 8.0.0
    var_dump(0 == 'abc'); //false
    
Copyright © 豆包嘿嘿~ 2012-∞ 冀ICP备17033181号 all right reserved,powered by Gitbook修订: 2021-01-04 02:27:22

results matching ""

    No results matching ""