1--TEST--
2Test fprintf() function (variation - 9)
3--SKIPIF--
4<?php
5$data_file = dirname(__FILE__) . '/dump.txt';
6if (!($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';
18if (!($fp = fopen($data_file, 'wt')))
19   return;
20
21$counter = 1;
22/* string type variations */
23fprintf($fp, "\n*** Testing fprintf() for string types ***\n");
24foreach( $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
33fclose($fp);
34
35print_r(file_get_contents($data_file));
36echo "\nDone";
37
38unlink($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
52abc
53aaa
54-- Iteration 3 --
55
5600000
5700abc
5800aaa
59-- Iteration 4 --
60
61#####
62##abc
63##aaa
64Done
65