printf_basic2.phpt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. --TEST--
  2. Test printf() function : basic functionality - integer 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 integer format ***\n";
  10. // Initialise all required variables
  11. $format = "format";
  12. $format1 = "%d";
  13. $format2 = "%d %d";
  14. $format3 = "%d %d %d";
  15. $arg1 = 111;
  16. $arg2 = 222;
  17. $arg3 = 333;
  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 arguments--\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 integer format ***
  38. -- Calling printf() with no arguments --
  39. format
  40. int(6)
  41. -- Calling printf() with one arguments--
  42. 111
  43. int(3)
  44. -- Calling printf() with two arguments--
  45. 111 222
  46. int(7)
  47. -- Calling printf() with three arguments--
  48. 111 222 333
  49. int(11)
  50. ===DONE===