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 unsigned formats and signed values and other types of values
9 * are passed to the '$format' and '$args' arguments of the function
12 echo "*** Testing vfprintf() : unsigned formats and signed & other types of values ***\n";
14 // defining array of unsigned formats
19 %\'#2u %\'2u %\'$2u %\'_2u
22 // Arrays of signed and other type of values for the format defined in $format.
23 // Each sub array contains signed values which correspond to each format in $format
26 // array of float values
27 array(+
2.2, +
.2, +
10.2,
28 +
123456.234, +
123456.234, +
1234.6789,
29 +
2e10
, +
2e12
, +
22e+12,
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", '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(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,
56 /* creating dumping file */
57 $data_file = dirname(__FILE__
) . '/vfprintf_variation16_64bit.phpt.txt';
58 if (!($fp = fopen($data_file, 'wt')))
61 // looping to test vfprintf() with different unsigned formats from the above $format array
62 // and with signed and other types of values from the above $args_array array
64 foreach($args_array as $args) {
65 fprintf($fp, "\n-- Iteration %d --\n",$counter);
66 vfprintf($fp, $formats, $args);
71 print_r(file_get_contents($data_file));