sprintf_basic1.phpt 940 B

123456789101112131415161718192021222324252627282930313233343536
  1. --TEST--
  2. Test sprintf() function : basic functionality - string format
  3. --FILE--
  4. <?php
  5. echo "*** Testing sprintf() : 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. // Calling sprintf() with default arguments
  15. var_dump( sprintf($format) );
  16. // Calling sprintf() with two arguments
  17. var_dump( sprintf($format1, $arg1) );
  18. // Calling sprintf() with three arguments
  19. var_dump( sprintf($format2, $arg1, $arg2) );
  20. // Calling sprintf() with four arguments
  21. var_dump( sprintf($format3, $arg1, $arg2, $arg3) );
  22. echo "Done";
  23. ?>
  24. --EXPECT--
  25. *** Testing sprintf() : basic functionality - using string format ***
  26. string(6) "format"
  27. string(13) "arg1 argument"
  28. string(27) "arg1 argument arg2 argument"
  29. string(41) "arg1 argument arg2 argument arg3 argument"
  30. Done