PageRenderTime 36ms CodeModel.GetById 10ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://github.com/facebook/hiphop-php
PHP | 37 lines | 24 code | 7 blank | 6 comment | 1 complexity | 8e111c2f97755206e8ee227d22cadd37 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 string format ***\n";
  8. // Initialise all required variables
  9. $format = "format";
  10. $format1 = "%s\n";
  11. $format2 = "%s %s\n";
  12. $format3 = "%s %s %s\n";
  13. $arg1 = varray["one"];
  14. $arg2 = varray["one","two"];
  15. $arg3 = varray["one","two","three"];
  16. /* creating dumping file */
  17. $data_file = dirname(__FILE__) . '/vfprintf_basic1.txt';
  18. if (!($fp = fopen($data_file, 'wt')))
  19. return;
  20. $result = vfprintf($fp, $format1, $arg1);
  21. var_dump($result);
  22. $result = vfprintf($fp, $format2, $arg2);
  23. var_dump($result);
  24. $result = vfprintf($fp, $format3, $arg3);
  25. var_dump($result);
  26. fclose($fp);
  27. print_r(file_get_contents($data_file));
  28. unlink($data_file);
  29. echo "===DONE===\n";
  30. }