2
Test vfprintf() function : usage variations - int formats with non-integer values
5
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
9
/* Prototype : int vfprintf ( resource $handle , string $format , array $args )
10
* Description: Write a formatted string to a stream
11
* Source code: ext/standard/formatted_print.c
15
* Test vfprintf() when different int formats and non-int values are passed to
16
* the '$format' and '$args' arguments of the function
19
echo "*** Testing vfprintf() : int formats and non-integer values ***\n";
21
// defining array of int formats
25
%10.4d %-10.4d %.4d %04.4d
26
%\'#2d %\'2d %\'$2d %\'_2d
29
// Arrays of non int values for the format defined in $format.
30
// Each sub array contains non int values which correspond to each format in $format
33
// array of float values
35
123456.234, 123456.234, -1234.6789, +1234.6789,
36
2e10, +2e5, 4e3, 22e+6,
37
12345.780, 12.000000011111, -12.00000111111, -123456.234,
38
3.33, +4.44, 1.11,-2.22 ),
41
array(" ", ' ', 'hello',
42
'123hello', "123hello", '-123hello', '+123hello',
43
"\12345678hello", "-\12345678hello", '0123456hello', 'h123456ello',
44
"1234hello", "hello\0world", "NULL", "true",
48
array( array(0), array(1, 2), array(-1, -1),
49
array("123"), array('123'), array('-123'), array("-123"),
50
array(true), array(false), array(TRUE), array(FALSE),
51
array("123hello"), array("1", "2"), array('123hello'), array(12=>"12twelve"),
52
array("3"), array("4"), array("1"), array("2") ),
54
// array of boolean data
55
array( true, TRUE, false,
57
true, false, TRUE, FALSE,
64
/* creating dumping file */
65
$data_file = dirname(__FILE__) . '/dump.txt';
66
if (!($fp = fopen($data_file, 'wt')))
69
// looping to test vfprintf() with different int formats from the above $format array
70
// and with non-int values from the above $args_array array
72
foreach($args_array as $args) {
73
fprintf($fp, "\n-- Iteration %d --\n",$counter);
74
vfprintf($fp, $formats, $args);
79
print_r(file_get_contents($data_file));
87
*** Testing vfprintf() : int formats and non-integer values ***
92
20000000000 200000 4000 22000000