printf_basic5.phpt 1.3 KB

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