Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- php operator == (sort of equality) and the integer 0
- <?php
- print "number of surprised persons: " . ('false' == 0);
- number of surprised persons: 1
- 0 <-- integer
- false <-- boolean
- null <-- just.. you know, null
- '0' <-- string
- '' <-- string
- 'false' <-- string
- 'true' <-- string
- 'null' <-- string
- 'true' == 0
- // is the same as
- (int)'true' == 0
- // is the same as
- 0 == 0
- // is the same as
- true
- Example Name Result
- $a == $b Equal TRUE if $a is equal to $b after type juggling.
- <?php
- print "number of surprised persons: " . ('false' == 0.3 - 0.2 - 0.1);
- $a = true;
- echo "$a"; #1
Add Comment
Please, Sign In to add comment