PHP Type Comparison
Although PHP is a loosely typed language, you still need to understand variable types and their meanings, because we often need to compare PHP variables, including loose and strict comparison.
- Loose comparison: uses two equal signs == to compare, comparing only values, not types.
- Strict comparison: uses three equal signs === to compare, comparing both values and types.
For example, "42" is a string while 42 is an integer. FALSE is a boolean while "FALSE" is a string.
Example
The output of the above example is:
1、值相等
3、类型不相等
Comparing 0, false, null in PHP
Test code: