PageRenderTime 38ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/test/zend/good/ext/standard/tests/strings/vfprintf_basic3.php

http://github.com/facebook/hiphop-php
PHP | 51 lines | 33 code | 12 blank | 6 comment | 1 complexity | 2cd87930d21cb140d53b6e4b62d88660 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
  1. <?hh
  2. /* Prototype : int vfprintf ( resource $handle , string $format , array $args )
  3. * Description: Write a formatted string to a stream
  4. * Source code: ext/standard/formatted_print.c
  5. */
  6. <<__EntryPoint>> function main(): void {
  7. echo "*** Testing vfprintf() : basic functionality - using float format ***\n";
  8. // Initialise all required variables
  9. $format = "format";
  10. $format1 = "%f";
  11. $format2 = "%f %f";
  12. $format3 = "%f %f %f";
  13. $format11 = "%F";
  14. $format22 = "%F %F";
  15. $format33 = "%F %F %F";
  16. $arg1 = varray[11.11];
  17. $arg2 = varray[11.11,22.22];
  18. $arg3 = varray[11.11,22.22,33.33];
  19. /* creating dumping file */
  20. $data_file = dirname(__FILE__) . '/vfprintf_basic3.txt';
  21. if (!($fp = fopen($data_file, 'wt')))
  22. return;
  23. vfprintf($fp, $format1,$arg1);
  24. fprintf($fp, "\n");
  25. vfprintf($fp,$format11,$arg1);
  26. fprintf($fp, "\n");
  27. vfprintf($fp,$format2,$arg2);
  28. fprintf($fp, "\n");
  29. vfprintf($fp,$format22,$arg2);
  30. fprintf($fp, "\n");
  31. vfprintf($fp,$format3,$arg3);
  32. fprintf($fp, "\n");
  33. vfprintf($fp, $format33,$arg3);
  34. fprintf($fp, "\n");
  35. fclose($fp);
  36. print_r(file_get_contents($data_file));
  37. unlink($data_file);
  38. echo "===DONE===\n";
  39. }