sprintf_basic7.phpt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. --TEST--
  2. Test sprintf() function : basic functionality - unsigned format
  3. --SKIPIF--
  4. <?php
  5. if (PHP_INT_SIZE != 4) {
  6. die("skip this test is for 32bit platform only");
  7. }
  8. ?>
  9. --FILE--
  10. <?php
  11. /* Prototype : string sprintf(string $format [, mixed $arg1 [, mixed ...]])
  12. * Description: Return a formatted string
  13. * Source code: ext/standard/formatted_print.c
  14. */
  15. echo "*** Testing sprintf() : basic functionality - using unsigned format ***\n";
  16. // Initialise all required variables
  17. $format = "format";
  18. $format1 = "%u";
  19. $format2 = "%u %u";
  20. $format3 = "%u %u %u";
  21. $arg1 = -1111;
  22. $arg2 = -1234567;
  23. $arg3 = +2345432;
  24. // Calling sprintf() with default arguments
  25. var_dump( sprintf($format) );
  26. // Calling sprintf() with two arguments
  27. var_dump( sprintf($format1, $arg1) );
  28. // Calling sprintf() with three arguments
  29. var_dump( sprintf($format2, $arg1, $arg2) );
  30. // Calling sprintf() with four arguments
  31. var_dump( sprintf($format3, $arg1, $arg2, $arg3) );
  32. echo "Done";
  33. ?>
  34. --EXPECTF--
  35. *** Testing sprintf() : basic functionality - using unsigned format ***
  36. string(6) "format"
  37. string(10) "4294966185"
  38. string(21) "4294966185 4293732729"
  39. string(29) "4294966185 4293732729 2345432"
  40. Done