vfprintf_basic3.phpt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. --TEST--
  2. Test vfprintf() function : basic functionality - float 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 float format ***\n";
  10. // Initialise all required variables
  11. $format = "format";
  12. $format1 = "%f";
  13. $format2 = "%f %f";
  14. $format3 = "%f %f %f";
  15. $format11 = "%F";
  16. $format22 = "%F %F";
  17. $format33 = "%F %F %F";
  18. $arg1 = array(11.11);
  19. $arg2 = array(11.11,22.22);
  20. $arg3 = array(11.11,22.22,33.33);
  21. /* creating dumping file */
  22. $data_file = dirname(__FILE__) . '/vfprintf_basic3.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 float format ***
  44. 11.110000
  45. 11.110000
  46. 11.110000 22.220000
  47. 11.110000 22.220000
  48. 11.110000 22.220000 33.330000
  49. 11.110000 22.220000 33.330000
  50. ===DONE===