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

/hphp/test/zend/flaky/ext/standard/tests/strings/fprintf_variation_001.php

http://github.com/facebook/hiphop-php
PHP | 30 lines | 29 code | 1 blank | 0 comment | 0 complexity | 962696c68ef24b6fac8eeb4726191c1d 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. <?php
  2. $float_variation = array( "%f","%-f", "%+f", "%7.2f", "%-7.2f", "%07.2f", "%-07.2f", "%'#7.2f" );
  3. $float_numbers = array( 0, 1, -1, 0.32, -0.32, 3.4. -3.4, 2.54, -2.54 );
  4. /* creating dumping file */
  5. $data_file = dirname(__FILE__) . '/fprintf_variation_001.phpt.txt';
  6. if (!($fp = fopen($data_file, 'wt')))
  7. return;
  8. $counter = 1;
  9. /* float type variations */
  10. fprintf($fp, "\n*** Testing fprintf() with floats ***\n");
  11. foreach( $float_variation as $float_var ) {
  12. fprintf( $fp, "\n-- Iteration %d --\n",$counter);
  13. foreach( $float_numbers as $float_num ) {
  14. fprintf( $fp, "\n");
  15. fprintf( $fp, $float_var, $float_num );
  16. }
  17. $counter++;
  18. }
  19. fclose($fp);
  20. print_r(file_get_contents($data_file));
  21. echo "\nDone";
  22. unlink($data_file);
  23. ?>