见过好多代码用三个等号做判断,为什么?
两个等号有什么缺点?

解决方案 »

  1.   


    ===会同时检查值与类型;eg:
    $a='0';
    $b='false';
    if($a==$b)echo'true';
    else echo 'false';
    输出true如果$a===$b输出为false
      

  2.   

    丢人了,例子写错了!!!555555555555555这样举例合适:范例1:$string="10 minutes";$int=10;if ($string==$int)echo "It is true";elseecho "It is false";显示:It is true解析:$string会被自动转化成整形变量,$string=10。因此,条件表达式成立!范例2:$string="10 minutes";$int=10;if ($string===$int)echo "It is true";elseecho "It is false";显示:It is false