decbin_basic.phpt 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. --TEST--
  2. Test decbin() - basic function test
  3. --FILE--
  4. <?php
  5. $values = array(10,
  6. 3950.5,
  7. 3.9505e3,
  8. 03,
  9. 0x5F,
  10. "10",
  11. "3950.5",
  12. "3.9505e3",
  13. "039",
  14. "0x5F",
  15. true,
  16. false,
  17. );
  18. foreach ($values as $value) {
  19. try {
  20. var_dump(decbin($value));
  21. } catch (TypeError $exception) {
  22. echo $exception->getMessage() . "\n";
  23. }
  24. }
  25. ?>
  26. --EXPECTF--
  27. string(4) "1010"
  28. Deprecated: Implicit conversion from float 3950.5 to int loses precision in %s on line %d
  29. string(12) "111101101110"
  30. Deprecated: Implicit conversion from float 3950.5 to int loses precision in %s on line %d
  31. string(12) "111101101110"
  32. string(2) "11"
  33. string(7) "1011111"
  34. string(4) "1010"
  35. Deprecated: Implicit conversion from float-string "3950.5" to int loses precision in %s on line %d
  36. string(12) "111101101110"
  37. Deprecated: Implicit conversion from float-string "3.9505e3" to int loses precision in %s on line %d
  38. string(12) "111101101110"
  39. string(6) "100111"
  40. decbin(): Argument #1 ($num) must be of type int, string given
  41. string(1) "1"
  42. string(1) "0"