sprintf_variation4.phpt 555 B

123456789101112131415161718192021222324
  1. --TEST--
  2. sprintf %u With signed integer 32bit
  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. /* example#5: various examples */
  12. $n = 43951789;
  13. $u = -43951789;
  14. // notice the double %%, this prints a literal '%' character
  15. var_dump(sprintf("%%u = '%u'", $n)); // unsigned integer representation of a positive integer
  16. var_dump(sprintf("%%u = '%u'", $u)); // unsigned integer representation of a negative integer
  17. ?>
  18. --EXPECT--
  19. string(15) "%u = '43951789'"
  20. string(17) "%u = '4251015507'"