vfprintf_basic2.phpt 1.1 KB

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