printf_basic1.phpt 1.4 KB

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