zoukankan      html  css  js  c++  java
  • 关于empty函数的判断

    $a = '';
    echo '1.-----------'.($a == '').'<br>';
    echo '2.-----------'.($a == null).'<br>';
    echo '3.-----------'.($a == false).'<br>';
    echo '4.-----------'.($a == '0').'<br>';
    echo '5.-----------'.($a == 0).'<br>';
    $a = null;
    echo '6.-----------'.($a == '').'<br>';
    echo '7.-----------'.($a == null).'<br>';
    echo '8.-----------'.($a == false).'<br>';
    echo '9.-----------'.($a == '0').'<br>';
    echo '10.-----------'.($a == 0).'<br>';
    $a = '0';
    echo '11.-----------'.($a == '').'<br>';
    echo '12.-----------'.($a == null).'<br>';
    echo '13.-----------'.($a == false).'<br>';
    echo '14.-----------'.($a == '0').'<br>';
    echo '15.-----------'.($a == 0).'<br>';
    $a = 0;
    echo '16.-----------'.($a == '').'<br>';
    echo '17.-----------'.($a == null).'<br>';
    echo '18.-----------'.($a == false).'<br>';
    echo '19.-----------'.($a == '0').'<br>';
    echo '20.-----------'.($a == 0).'<br>';
    $a = false;
    echo '21.-----------'.($a == '').'<br>';
    echo '22.-----------'.($a == null).'<br>';
    echo '23.-----------'.($a == false).'<br>';
    echo '24.-----------'.($a == '0').'<br>';
    echo '25.-----------'.($a == 0).'<br>';

    输出的结果

    1.-----------1
    2.-----------1
    3.-----------1
    4.-----------
    5.-----------1
    6.-----------1
    7.-----------1
    8.-----------1
    9.-----------
    10.-----------1
    11.-----------
    12.-----------
    13.-----------1
    14.-----------1
    15.-----------1
    16.-----------1
    17.-----------1
    18.-----------1
    19.-----------1
    20.-----------1
    21.-----------1
    22.-----------1
    23.-----------1
    24.-----------1
    25.-----------1

    $a = '';//0|'0'|false|null 输出的结果一致
    echo '1.-------'.(!empty($a) == '').'<br>';
    echo '2.-------'.(!empty($a) == null).'<br>';
    echo '3.-------'.(!empty($a) == false).'<br>';
    echo '4.-------'.(!empty($a) == '0').'<br>';
    echo '5.-------'.(!empty($a) == 0).'<br>';

    输出的结果:

    1.-------1
    2.-------1
    3.-------1
    4.-------1
    5.-------1

  • 相关阅读:
    C++类的成员函数的指针和mem_fun适配器的用法
    C++ RTTI的使用
    C++特殊工具与技术之RTTI
    Linux组件封装之五:生产者消费者问题
    Linux组件封装之四:RAII实现MutexLock自动化解锁
    Linux组件封装之三:Thread
    Linux组件封装之二:Condition
    Linux组件封装之一:MUtexLock
    C++ socket与Flex as3通信的沙盒问题解决
    CentOS搭建PHP环境
  • 原文地址:https://www.cnblogs.com/xingmeng/p/3081689.html
Copyright © 2011-2022 走看看