vfprintf_basic9.phpt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. --TEST--
  2. Test vfprintf) function : basic functionality - hexadecimal format
  3. --FILE--
  4. <?php
  5. /* Prototype : int vfprintf ( resource $handle , string $format , array $args )
  6. * Description: Write a formatted string to a stream
  7. * Source code: ext/standard/formatted_print.c
  8. */
  9. echo "*** Testing vfprintf) : basic functionality - using hexadecimal format ***\n";
  10. // Initialising different format strings
  11. $format = "format";
  12. $format1 = "%x";
  13. $format2 = "%x %x";
  14. $format3 = "%x %x %x";
  15. $format11 = "%X";
  16. $format22 = "%X %X";
  17. $format33 = "%X %X %X";
  18. $arg1 = array(11);
  19. $arg2 = array(11,132);
  20. $arg3 = array(11,132,177);
  21. /* creating dumping file */
  22. $data_file = dirname(__FILE__) . '/vfprintf_basic9.txt';
  23. if (!($fp = fopen($data_file, 'wt')))
  24. return;
  25. vfprintf($fp, $format1, $arg1);
  26. fprintf($fp, "\n");
  27. vfprintf($fp, $format11, $arg1);
  28. fprintf($fp, "\n");
  29. vfprintf($fp, $format2, $arg2);
  30. fprintf($fp, "\n");
  31. vfprintf($fp, $format22, $arg2);
  32. fprintf($fp, "\n");
  33. vfprintf($fp, $format3, $arg3);
  34. fprintf($fp, "\n");
  35. vfprintf($fp, $format33, $arg3);
  36. fprintf($fp, "\n");
  37. fclose($fp);
  38. print_r(file_get_contents($data_file));
  39. unlink($data_file);
  40. ?>
  41. ===DONE===
  42. --EXPECT--
  43. *** Testing vfprintf) : basic functionality - using hexadecimal format ***
  44. b
  45. B
  46. b 84
  47. B 84
  48. b 84 b1
  49. B 84 B1
  50. ===DONE===