if判断为false的6种情况

class TestController extends Controller
{
    function actionIndex()
    {
        $temp = '';//空字符串
        $this->test_false($temp);

        $temp = '0';//字符串0
        $this->test_false($temp);

        $temp = 0;//整型0
        $this->test_false($temp);

        $temp = 0.00;//浮点型0
        $this->test_false($temp);

        $temp = [];//浮点型0
        $this->test_false($temp);

        $temp = null;//浮点型0
        $this->test_false($temp);
        exit();
    }

    function test_false($data)
    {
        if ($data){
            p('true');
        }else{
            p('false');
        }
    }
}
输出结果:
        false
        false
        false
        false
        false
        false
原文地址:https://www.cnblogs.com/aj407blogs/p/13129141.html