Annotation of embedaddon/php/ext/standard/tests/strings/fprintf_variation_009.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test fprintf() function (variation - 9)
! 3: --SKIPIF--
! 4: <?php
! 5: $data_file = dirname(__FILE__) . '/dump.txt';
! 6: if (!($fp = fopen($data_file, 'w'))) {
! 7: die('skip File dump.txt could not be created');
! 8: }
! 9: ?>
! 10: --FILE--
! 11: <?php
! 12:
! 13: $string_variation = array( "%5s", "%-5s", "%05s", "%'#5s" );
! 14: $strings = array( NULL, "abc", 'aaa' );
! 15:
! 16: /* creating dumping file */
! 17: $data_file = dirname(__FILE__) . '/dump.txt';
! 18: if (!($fp = fopen($data_file, 'wt')))
! 19: return;
! 20:
! 21: $counter = 1;
! 22: /* string type variations */
! 23: fprintf($fp, "\n*** Testing fprintf() for string types ***\n");
! 24: foreach( $string_variation as $string_var ) {
! 25: fprintf( $fp, "\n-- Iteration %d --\n",$counter);
! 26: foreach( $strings as $str ) {
! 27: fprintf( $fp, "\n");
! 28: fprintf( $fp, $string_var, $str );
! 29: }
! 30: $counter++;
! 31: }
! 32:
! 33: fclose($fp);
! 34:
! 35: print_r(file_get_contents($data_file));
! 36: echo "\nDone";
! 37:
! 38: unlink($data_file);
! 39:
! 40: ?>
! 41: --EXPECTF--
! 42: *** Testing fprintf() for string types ***
! 43:
! 44: -- Iteration 1 --
! 45:
! 46:
! 47: abc
! 48: aaa
! 49: -- Iteration 2 --
! 50:
! 51:
! 52: abc
! 53: aaa
! 54: -- Iteration 3 --
! 55:
! 56: 00000
! 57: 00abc
! 58: 00aaa
! 59: -- Iteration 4 --
! 60:
! 61: #####
! 62: ##abc
! 63: ##aaa
! 64: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>