printf_basic5.phpt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. --TEST--
  2. Test printf() function : basic functionality - char format
  3. --FILE--
  4. <?php
  5. echo "*** Testing printf() : basic functionality - using char format ***\n";
  6. // Initialise all required variables
  7. $format = "format";
  8. $format1 = "%c";
  9. $format2 = "%c %c";
  10. $format3 = "%c %c %c";
  11. $arg1 = 65;
  12. $arg2 = 66;
  13. $arg3 = 67;
  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 arguments --\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 char format ***
  33. -- Calling printf() with no arguments --
  34. format
  35. int(6)
  36. -- Calling printf() with one arguments --
  37. A
  38. int(1)
  39. -- Calling printf() with two arguments --
  40. A B
  41. int(3)
  42. -- Calling printf() with three arguments --
  43. A B C
  44. int(5)