sprintf_basic4.phpt 1001 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. --TEST--
  2. Test sprintf() function : basic functionality - bool format
  3. --FILE--
  4. <?php
  5. /* Prototype : string sprintf(string $format [, mixed $arg1 [, mixed ...]])
  6. * Description: Return a formatted string
  7. * Source code: ext/standard/formatted_print.c
  8. */
  9. echo "*** Testing sprintf() : basic functionality - using bool format ***\n";
  10. // Initialise all required variables
  11. $format = "format";
  12. $format1 = "%b";
  13. $format2 = "%b %b";
  14. $format3 = "%b %b %b";
  15. $arg1 = TRUE;
  16. $arg2 = FALSE;
  17. $arg3 = true;
  18. // Calling sprintf() with default arguments
  19. var_dump( sprintf($format) );
  20. // Calling sprintf() with two arguments
  21. var_dump( sprintf($format1, $arg1) );
  22. // Calling sprintf() with three arguments
  23. var_dump( sprintf($format2, $arg1, $arg2) );
  24. // Calling sprintf() with four arguments
  25. var_dump( sprintf($format3, $arg1, $arg2, $arg3) );
  26. echo "Done";
  27. ?>
  28. --EXPECTF--
  29. *** Testing sprintf() : basic functionality - using bool format ***
  30. string(6) "format"
  31. string(1) "1"
  32. string(3) "1 0"
  33. string(5) "1 0 1"
  34. Done