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
8 * Test vfprintf() when different int formats and non-int values are passed to
9 * the '$format' and '$args' arguments of the function
12 echo "*** Testing vfprintf() : int formats and non-integer values ***\n";
14 // defining array of int formats
18 %10.4d %-10.4d %.4d %04.4d
19 %\'#2d %\'2d %\'$2d %\'_2d
22 // Arrays of non int values for the format defined in $format.
23 // Each sub array contains non int values which correspond to each format in $format
26 // array of float values
28 123456.234, 123456.234, -1234.6789, +
1234.6789,
29 2e10
, +
2e5
, 4e3
, 22e+6,
30 12345.780, 12.000000011111, -12.00000111111, -123456.234,
31 3.33, +
4.44, 1.11,-2.22 ),
34 array(" ", ' ', 'hello',
35 '123hello', "123hello", '-123hello', '+123hello',
36 "\12345678hello", "-\12345678hello", '0123456hello', 'h123456ello',
37 "1234hello", "hello\0world", "NULL", "true",
41 array( array(0), array(1, 2), array(-1, -1),
42 array("123"), array('123'), array('-123'), array("-123"),
43 array(true), array(false), array(TRUE), array(FALSE),
44 array("123hello"), array("1", "2"), array('123hello'), array(12=>"12twelve"),
45 array("3"), array("4"), array("1"), array("2") ),
47 // array of boolean data
48 array( true, TRUE, false,
50 true, false, TRUE, FALSE,
57 /* creating dumping file */
58 $data_file = dirname(__FILE__
) . '/vfprintf_variation4_64bit.phpt.txt';
59 if (!($fp = fopen($data_file, 'wt')))
62 // looping to test vfprintf() with different int formats from the above $format array
63 // and with non-int values from the above $args_array array
65 foreach($args_array as $args) {
66 fprintf($fp, "\n-- Iteration %d --\n",$counter);
67 vfprintf($fp, $formats, $args);
72 print_r(file_get_contents($data_file));