The reason is that variables are stored in C language structures in PHP. Empty strings, NULL, and false are all stored with a value of 0. null, 0, and false are all judged as 0 without distinguishing types. Logical false means false
See the PHP manual, the picture below is taken from the PHP manual
This table shows the processing of the left and right operators by PHP binary operators.
It can be seen that 0 == null, one operator is a number, and the other operator is null, which conforms to the second case in the table, so according to the description, both sides are converted into corresponding Boolean values at the same time, that is Say 0 and null are converted to false, so false == false is true.
The reason is that variables are stored in C language structures in PHP. Empty strings, NULL, and false are all stored with a value of 0.
null, 0, and false are all judged as 0 without distinguishing types. Logical false means false
See the PHP manual, the picture below is taken from the PHP manual
This table shows the processing of the left and right operators by PHP binary operators.
It can be seen that
0 == null
, one operator is a number, and the other operator isnull
, which conforms to the second case in the table, so according to the description, both sides are converted into corresponding Boolean values at the same time, that is Say0
andnull
are converted tofalse
, sofalse == false
istrue
.