Guest User

Untitled

a guest
Aug 20th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. php operator == (sort of equality) and the integer 0
  2. <?php
  3. print "number of surprised persons: " . ('false' == 0);
  4.  
  5. number of surprised persons: 1
  6.  
  7. 0 <-- integer
  8. false <-- boolean
  9. null <-- just.. you know, null
  10. '0' <-- string
  11. '' <-- string
  12. 'false' <-- string
  13. 'true' <-- string
  14. 'null' <-- string
  15.  
  16. 'true' == 0
  17. // is the same as
  18. (int)'true' == 0
  19. // is the same as
  20. 0 == 0
  21. // is the same as
  22. true
  23.  
  24. Example Name Result
  25. $a == $b Equal TRUE if $a is equal to $b after type juggling.
  26.  
  27. <?php
  28. print "number of surprised persons: " . ('false' == 0.3 - 0.2 - 0.1);
  29.  
  30. $a = true;
  31. echo "$a"; #1
Add Comment
Please, Sign In to add comment