printf_basic7.phpt 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. --TEST--
  2. Test printf() 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 : int printf ( string $format [, mixed $args [, mixed $... ]] )
  12. * Description: Produces output according to format .
  13. * Source code: ext/standard/formatted_print.c
  14. */
  15. echo "*** Testing printf() : 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. echo "\n-- Calling printf() with no arguments --\n";
  25. $result = printf($format);
  26. echo "\n";
  27. var_dump($result);
  28. echo "\n-- Calling printf() with one arguments --\n";
  29. $result = printf($format1, $arg1);
  30. echo "\n";
  31. var_dump($result);
  32. echo "\n-- Calling printf() with two arguments --\n";
  33. $result = printf($format2, $arg1, $arg2);
  34. echo "\n";
  35. var_dump($result);
  36. echo "\n-- Calling printf() with three arguments --\n";
  37. $result = printf($format3, $arg1, $arg2, $arg3);
  38. echo "\n";
  39. var_dump($result);
  40. ?>
  41. ===DONE===
  42. --EXPECTF--
  43. *** Testing printf() : basic functionality - using unsigned format ***
  44. -- Calling printf() with no arguments --
  45. format
  46. int(6)
  47. -- Calling printf() with one arguments --
  48. 4294966185
  49. int(10)
  50. -- Calling printf() with two arguments --
  51. 4294966185 4293732729
  52. int(21)
  53. -- Calling printf() with three arguments --
  54. 4294966185 4293732729 2345432
  55. int(29)
  56. ===DONE===