printf_basic6.phpt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. --TEST--
  2. Test printf() function : basic functionality - exponential format
  3. --FILE--
  4. <?php
  5. /* Prototype : int printf ( string $format [, mixed $args [, mixed $... ]] )
  6. * Description: Produces output according to format .
  7. * Source code: ext/standard/formatted_print.c
  8. */
  9. echo "*** Testing printf() : basic functionality - using exponential format ***\n";
  10. // Initialise all required variables
  11. $format = "format";
  12. $format1 = "%e";
  13. $format2 = "%E %e";
  14. $format3 = "%e %E %e";
  15. $arg1 = 1000;
  16. $arg2 = 2e3;
  17. $arg3 = +3e3;
  18. echo "\n-- Calling printf() with no arguments --\n";
  19. $result = printf($format);
  20. echo "\n";
  21. var_dump($result);
  22. echo "\n-- Calling printf() with one argument --\n";
  23. $result = printf($format1, $arg1);
  24. echo "\n";
  25. var_dump($result);
  26. echo "\n-- Calling printf() with two arguments --\n";
  27. $result = printf($format2, $arg1, $arg2);
  28. echo "\n";
  29. var_dump($result);
  30. echo "\n-- Calling printf() with three arguments --\n";
  31. $result = printf($format3, $arg1, $arg2, $arg3);
  32. echo "\n";
  33. var_dump($result);
  34. ?>
  35. ===DONE===
  36. --EXPECTF--
  37. *** Testing printf() : basic functionality - using exponential format ***
  38. -- Calling printf() with no arguments --
  39. format
  40. int(6)
  41. -- Calling printf() with one argument --
  42. 1.000000e+3
  43. int(11)
  44. -- Calling printf() with two arguments --
  45. 1.000000E+3 2.000000e+3
  46. int(23)
  47. -- Calling printf() with three arguments --
  48. 1.000000e+3 2.000000E+3 3.000000e+3
  49. int(35)
  50. ===DONE===