printf_basic8.phpt 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. /* 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 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. 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 octal format ***
  44. -- Calling printf() with no arguments --
  45. format
  46. int(6)
  47. -- Calling printf() with one arguments --
  48. 21
  49. int(2)
  50. -- Calling printf() with two arguments --
  51. 21 37777777431
  52. int(14)
  53. -- Calling printf() with three arguments --
  54. 21 37777777431 567
  55. int(18)
  56. ===DONE===