sprintf_basic8.phpt 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. --TEST--
  2. Test sprintf() function : basic functionality - octal 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 octal format ***\n";
  16. // Initialise all required variables
  17. $format = "format";
  18. $format1 = "%o";
  19. $format2 = "%o %o";
  20. $format3 = "%o %o %o";
  21. $arg1 = 021;
  22. $arg2 = -0347;
  23. $arg3 = 05678;
  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 octal format ***
  36. string(6) "format"
  37. string(2) "21"
  38. string(14) "21 37777777431"
  39. string(18) "21 37777777431 567"
  40. Done