php中0,'',null,false,true,FLASE,TREU,array()的相等恒等学习
"Null" means "nothing". The var has not been initialized.
"False" means "not true in a boolean context". Used to explicitely show you are dealing with logical issues.
0 is an int. Nothing to do with the rest above, used for mathematics.
Now, what is tricky, it's that in dynamic languages like PHP, all of them have a value in a boolean context, which is "False".
If you test it with "==", it's testing the boolean value, so you will get equality. If you test it with "===", it will test the type, and you will get inequality.
//比较值 '' NULL 0 false true FALSE TRUE arrau()
//相等判断
//'' == NULL == 0 == false=="0" (相等)
//array() = 0 == NULL == false="0" (相等)
//array() <> '' (不相等)
//恒等判断
//任何两个数比较都不恒等
//相等判断
//'' == NULL == 0 == false=="0" (相等)
//array() = 0 == NULL == false="0" (相等)
//array() <> '' (不相等)
//恒等判断
//任何两个数比较都不恒等
//var_dump(false == FALSE); //bool(true)
//var_dump(false === FALSE); //bool(true)
//var_dump(true == TRUE); //bool(true)
//var_dump(true === TRUE); //bool(true)
//var_dump(false === FALSE); //bool(true)
//var_dump(true == TRUE); //bool(true)
//var_dump(true === TRUE); //bool(true)
//var_dump('' == NULL); //bool(true)
//var_dump('' === NULL); //bool(false)
//var_dump('' == 0); //bool(true)
//var_dump('' === 0); //bool(false)
//var_dump('' == false); //bool(true)
//var_dump('' === false); //bool(false)
//var_dump('' == true); //bool(false)
//var_dump('' === true); //bool(false)
//var_dump('' === NULL); //bool(false)
//var_dump('' == 0); //bool(true)
//var_dump('' === 0); //bool(false)
//var_dump('' == false); //bool(true)
//var_dump('' === false); //bool(false)
//var_dump('' == true); //bool(false)
//var_dump('' === true); //bool(false)
//var_dump(null == 0); //bool(true)
//var_dump(null === 0); //bool(false)
//var_dump(null == false); //bool(true)
//var_dump(null === false); //bool(false)
//var_dump(null == true); //bool(false)
//var_dump(null === true); //bool(false)
//var_dump(null === 0); //bool(false)
//var_dump(null == false); //bool(true)
//var_dump(null === false); //bool(false)
//var_dump(null == true); //bool(false)
//var_dump(null === true); //bool(false)
//var_dump(0 == false); //bool(true)
//var_dump(0 === false); //bool(false)
//var_dump(0 == true); //bool(false)
//var_dump(0 === true); //bool(false)
//var_dump(0 === false); //bool(false)
//var_dump(0 == true); //bool(false)
//var_dump(0 === true); //bool(false)
//对true的一些判断
//var_dump('1' == true); //bool(true)
//var_dump('1' === true); //bool(false)
//var_dump(1 == true); //bool(true)
//var_dump(1 === true); //bool(false)
//var_dump(array() == true); //bool(false)
//var_dump(array() === true); //bool(false)
//var_dump('1' == true); //bool(true)
//var_dump('1' === true); //bool(false)
//var_dump(1 == true); //bool(true)
//var_dump(1 === true); //bool(false)
//var_dump(array() == true); //bool(false)
//var_dump(array() === true); //bool(false)
//array()比较
//var_dump(array() == ''); //bool(false)
//var_dump(array() === ''); //bool(false)
//var_dump(array() == NULL); //bool(true)
//var_dump(array() === NULL); //bool(false)
//var_dump(array() == 0); //bool(false)
//var_dump(array() === 0); //bool(false)
//var_dump(array() == false); //bool(true)
//var_dump(array() === false); //bool(false)
//var_dump(array() == true); //bool(false)
//var_dump(array() === true); //bool(false)
//var_dump(array() == ''); //bool(false)
//var_dump(array() === ''); //bool(false)
//var_dump(array() == NULL); //bool(true)
//var_dump(array() === NULL); //bool(false)
//var_dump(array() == 0); //bool(false)
//var_dump(array() === 0); //bool(false)
//var_dump(array() == false); //bool(true)
//var_dump(array() === false); //bool(false)
//var_dump(array() == true); //bool(false)
//var_dump(array() === true); //bool(false)
//恒等比较
//var_dump(0 === '0'); //bool(false)
//var_dump(0 === 00); //bool(true)
//var_dump(00 === intval('0')); //bool(true)
//var_dump(0 === '0'); //bool(false)
//var_dump(0 === 00); //bool(true)
//var_dump(00 === intval('0')); //bool(true)