PageRenderTime 26ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://github.com/facebook/hiphop-php
PHP | 48 lines | 33 code | 9 blank | 6 comment | 1 complexity | 63f961b1f3bd1cc80a7003366d59fd3c 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 hexadecimal format ***\n";
  8. // Initialising different format strings
  9. $format = "format";
  10. $format1 = "%x";
  11. $format2 = "%x %x";
  12. $format3 = "%x %x %x";
  13. $format11 = "%X";
  14. $format22 = "%X %X";
  15. $format33 = "%X %X %X";
  16. $arg1 = varray[11];
  17. $arg2 = varray[11,132];
  18. $arg3 = varray[11,132,177];
  19. /* creating dumping file */
  20. $data_file = dirname(__FILE__) . '/vfprintf_basic9.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. }