vfprintf_basic1.phpt 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. --TEST--
  2. Test vfprintf() function : basic functionality - string 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 string format ***\n";
  10. // Initialise all required variables
  11. $format = "format";
  12. $format1 = "%s\n";
  13. $format2 = "%s %s\n";
  14. $format3 = "%s %s %s\n";
  15. $arg1 = array("one");
  16. $arg2 = array("one","two");
  17. $arg3 = array("one","two","three");
  18. /* creating dumping file */
  19. $data_file = dirname(__FILE__) . '/vfprintf_basic1.txt';
  20. if (!($fp = fopen($data_file, 'wt')))
  21. return;
  22. $result = vfprintf($fp, $format1, $arg1);
  23. var_dump($result);
  24. $result = vfprintf($fp, $format2, $arg2);
  25. var_dump($result);
  26. $result = vfprintf($fp, $format3, $arg3);
  27. var_dump($result);
  28. fclose($fp);
  29. print_r(file_get_contents($data_file));
  30. unlink($data_file);
  31. ?>
  32. ===DONE===
  33. --EXPECT--
  34. *** Testing vfprintf() : basic functionality - using string format ***
  35. int(4)
  36. int(8)
  37. int(14)
  38. one
  39. one two
  40. one two three
  41. ===DONE===