printf_basic1.phpt 1.2 KB

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