Difference between 0 and null in PHP: Difference between 0 and null in PHP
I do not know that when you store a field with the default data of 0 in the MySQL database, an error occurs when 0 or Null is determined in the program, because 0 and Null are not completely equal, seemingly simple, but difficult to judge
The value of Null and 0 is the same, but the type is not the same. The simple point is the difference between = and =. The first = is the same as the value, but = requires the same value and the same type of value.
Null is a special type. The two types are Null, for example, the following code:
1. $ var = NULL;
2. $ var;
3.0. "0", NULL, and objects without any attributes will be considered NULL.
See the following example.
Running result
'Equality ''' equal ''not equal'
Therefore, values of 0 and Null are equal, but their types are not equal. Well, I made a summary of the differences between PHP 0 and null. In short, if the points are unclear, it would be okay to make a few more judgments.