printf_basic2.phpt 1.1 KB

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