printf_basic6.phpt 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. --TEST--
  2. Test printf() function : basic functionality - exponential format
  3. --FILE--
  4. <?php
  5. echo "*** Testing printf() : basic functionality - using exponential format ***\n";
  6. // Initialise all required variables
  7. $format = "format";
  8. $format1 = "%e";
  9. $format2 = "%E %e";
  10. $format3 = "%e %E %e";
  11. $arg1 = 1000;
  12. $arg2 = 2e3;
  13. $arg3 = +3e3;
  14. echo "\n-- Calling printf() with no arguments --\n";
  15. $result = printf($format);
  16. echo "\n";
  17. var_dump($result);
  18. echo "\n-- Calling printf() with one argument --\n";
  19. $result = printf($format1, $arg1);
  20. echo "\n";
  21. var_dump($result);
  22. echo "\n-- Calling printf() with two arguments --\n";
  23. $result = printf($format2, $arg1, $arg2);
  24. echo "\n";
  25. var_dump($result);
  26. echo "\n-- Calling printf() with three arguments --\n";
  27. $result = printf($format3, $arg1, $arg2, $arg3);
  28. echo "\n";
  29. var_dump($result);
  30. ?>
  31. --EXPECT--
  32. *** Testing printf() : basic functionality - using exponential format ***
  33. -- Calling printf() with no arguments --
  34. format
  35. int(6)
  36. -- Calling printf() with one argument --
  37. 1.000000e+3
  38. int(11)
  39. -- Calling printf() with two arguments --
  40. 1.000000E+3 2.000000e+3
  41. int(23)
  42. -- Calling printf() with three arguments --
  43. 1.000000e+3 2.000000E+3 3.000000e+3
  44. int(35)