objects_001.phpt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. --TEST--
  2. comparing objects to other types
  3. --FILE--
  4. <?php
  5. class Bar {
  6. }
  7. $b = new Bar;
  8. var_dump($b == NULL);
  9. var_dump($b != NULL);
  10. var_dump($b == true);
  11. var_dump($b != true);
  12. var_dump($b == false);
  13. var_dump($b != false);
  14. var_dump($b == "");
  15. var_dump($b != "");
  16. var_dump($b == 0);
  17. var_dump($b != 0);
  18. var_dump($b == 1);
  19. var_dump($b != 1);
  20. var_dump($b == 1.0);
  21. var_dump($b != 1.0);
  22. var_dump($b == 1);
  23. echo "Done\n";
  24. ?>
  25. --EXPECTF--
  26. bool(false)
  27. bool(true)
  28. bool(true)
  29. bool(false)
  30. bool(false)
  31. bool(true)
  32. bool(false)
  33. bool(true)
  34. Notice: Object of class Bar could not be converted to int in %s on line %d
  35. bool(false)
  36. Notice: Object of class Bar could not be converted to int in %s on line %d
  37. bool(true)
  38. Notice: Object of class Bar could not be converted to int in %s on line %d
  39. bool(true)
  40. Notice: Object of class Bar could not be converted to int in %s on line %d
  41. bool(false)
  42. Notice: Object of class Bar could not be converted to float in %s on line %d
  43. bool(true)
  44. Notice: Object of class Bar could not be converted to float in %s on line %d
  45. bool(false)
  46. Notice: Object of class Bar could not be converted to int in %s on line %d
  47. bool(true)
  48. Done