abs_basic.phpt 767 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. --TEST--
  2. Test abs() function : basic functionality
  3. --INI--
  4. precision = 14
  5. --FILE--
  6. <?php
  7. /* Prototype : number abs ( mixed $number )
  8. * Description: Returns the absolute value of number.
  9. * Source code: ext/standard/math.c
  10. */
  11. echo "*** Testing abs() : basic functionality ***\n";
  12. $values = array(23,
  13. -23,
  14. 2.345e1,
  15. -2.345e1,
  16. 0x17,
  17. 027,
  18. "23",
  19. "-23",
  20. "23.45",
  21. "2.345e1",
  22. "-2.345e1",
  23. null,
  24. true,
  25. false);
  26. for ($i = 0; $i < count($values); $i++) {
  27. $res = abs($values[$i]);
  28. var_dump($res);
  29. }
  30. ?>
  31. ===Done===
  32. --EXPECTF--
  33. *** Testing abs() : basic functionality ***
  34. int(23)
  35. int(23)
  36. float(23.45)
  37. float(23.45)
  38. int(23)
  39. int(23)
  40. int(23)
  41. int(23)
  42. float(23.45)
  43. float(23.45)
  44. float(23.45)
  45. int(0)
  46. int(1)
  47. int(0)
  48. ===Done===