printf_basic9.phpt 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. --TEST--
  2. Test printf() function : basic functionality - hexadecimal format
  3. --FILE--
  4. <?php
  5. echo "*** Testing printf() : basic functionality - using hexadecimal format ***\n";
  6. // Initialise all required variables
  7. // Initialising different format strings
  8. $format = "format";
  9. $format1 = "%x";
  10. $format2 = "%x %x";
  11. $format3 = "%x %x %x";
  12. $format11 = "%X";
  13. $format22 = "%X %X";
  14. $format33 = "%X %X %X";
  15. $arg1 = 11;
  16. $arg2 = 132;
  17. $arg3 = 177;
  18. echo "\n-- Calling printf() with no arguments --\n";
  19. $result = printf($format);
  20. echo "\n";
  21. var_dump($result);
  22. echo "\n-- Calling printf() with one arguments --\n";
  23. $result = printf($format1, $arg1);
  24. echo "\n";
  25. var_dump($result);
  26. $result = printf($format11, $arg1);
  27. echo "\n";
  28. var_dump($result);
  29. echo "\n-- Calling printf() with two arguments --\n";
  30. $result = printf($format2, $arg1, $arg2);
  31. echo "\n";
  32. var_dump($result);
  33. $result = printf($format22, $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. $result = printf($format33, $arg1, $arg2, $arg3);
  41. echo "\n";
  42. var_dump($result);
  43. ?>
  44. --EXPECT--
  45. *** Testing printf() : basic functionality - using hexadecimal format ***
  46. -- Calling printf() with no arguments --
  47. format
  48. int(6)
  49. -- Calling printf() with one arguments --
  50. b
  51. int(1)
  52. B
  53. int(1)
  54. -- Calling printf() with two arguments --
  55. b 84
  56. int(4)
  57. B 84
  58. int(4)
  59. -- Calling printf() with three arguments --
  60. b 84 b1
  61. int(7)
  62. B 84 B1
  63. int(7)