PageRenderTime 41ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://github.com/facebook/hiphop-php
PHP | 42 lines | 24 code | 9 blank | 9 comment | 1 complexity | c5b6c30b32e0a00af3c56ef444c0360c 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. /*
  7. * Testing vfprintf() : basic functionality - using integer format
  8. */
  9. <<__EntryPoint>> function main(): void {
  10. echo "*** Testing vfprintf() : basic functionality - using integer format ***\n";
  11. // Initialise all required variables
  12. $format = "format";
  13. $format1 = "%d";
  14. $format2 = "%d %d";
  15. $format3 = "%d %d %d";
  16. $arg1 = varray[111];
  17. $arg2 = varray[111,222];
  18. $arg3 = varray[111,222,333];
  19. /* creating dumping file */
  20. $data_file = dirname(__FILE__) . '/vfprintf_basic2.txt';
  21. if (!($fp = fopen($data_file, 'wt')))
  22. return;
  23. vfprintf($fp, $format1, $arg1);
  24. fprintf($fp, "\n");
  25. vfprintf($fp, $format2, $arg2);
  26. fprintf($fp, "\n");
  27. vfprintf($fp, $format3, $arg3);
  28. fprintf($fp, "\n");
  29. fclose($fp);
  30. print_r(file_get_contents($data_file));
  31. unlink($data_file);
  32. echo "===DONE===\n";
  33. }