printf_basic8.phpt 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. --TEST--
  2. Test printf() 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. echo "*** Testing printf() : basic functionality - using octal format ***\n";
  12. // Initialise all required variables
  13. $format = "format";
  14. $format1 = "%o";
  15. $format2 = "%o %o";
  16. $format3 = "%o %o %o";
  17. $arg1 = 021;
  18. $arg2 = -0347;
  19. $arg3 = 0567;
  20. echo "\n-- Calling printf() with no arguments --\n";
  21. $result = printf($format);
  22. echo "\n";
  23. var_dump($result);
  24. echo "\n-- Calling printf() with one arguments --\n";
  25. $result = printf($format1, $arg1);
  26. echo "\n";
  27. var_dump($result);
  28. echo "\n-- Calling printf() with two arguments --\n";
  29. $result = printf($format2, $arg1, $arg2);
  30. echo "\n";
  31. var_dump($result);
  32. echo "\n-- Calling printf() with three arguments --\n";
  33. $result = printf($format3, $arg1, $arg2, $arg3);
  34. echo "\n";
  35. var_dump($result);
  36. ?>
  37. --EXPECT--
  38. *** Testing printf() : basic functionality - using octal format ***
  39. -- Calling printf() with no arguments --
  40. format
  41. int(6)
  42. -- Calling printf() with one arguments --
  43. 21
  44. int(2)
  45. -- Calling printf() with two arguments --
  46. 21 37777777431
  47. int(14)
  48. -- Calling printf() with three arguments --
  49. 21 37777777431 567
  50. int(18)