1--TEST--
2Test vprintf() function : usage variations - int formats with int values
3--FILE--
4<?php
5/*
6 * Test vprintf() when different int formats and int values are passed to
7 * the '$format' and '$args' arguments of the function
8*/
9
10echo "*** Testing vprintf() : int formats with int values ***\n";
11
12
13// defining array of int formats
14$formats = array(
15  "%d",
16  "%+d %-d",
17  "%ld %4d %-4d",
18  "%10.4d %-10.4d %04d %04.4d",
19  "%'#2d %'2d %'$2d %'_2d",
20  "%d %d %d %d",
21  "% %%d",
22  '%3$d %4$d %1$d %2$d'
23);
24
25// Arrays of int values for the format defined in $format.
26// Each sub array contains int values which correspond to each format string in $format
27$args_array = array(
28  array(0),
29  array(-1, 1),
30  array(2147483647, +2147483640, -2147483640),
31  array(123456, 12345678, -1234567, 1234567),
32  array(111, 2222, 333333, 44444444),
33  array(0x123b, 0xfAb, 0123, 012),
34  array(1234, -5678),
35  array(3, 4, 1, 2)
36
37);
38
39// looping to test vprintf() with different int formats from the above $format array
40// and with int values from the above $args_array array
41$counter = 1;
42foreach($formats as $format) {
43  echo "\n-- Iteration $counter --\n";
44  $result = vprintf($format, $args_array[$counter-1]);
45  echo "\n";
46  var_dump($result);
47  $counter++;
48}
49
50?>
51--EXPECT--
52*** Testing vprintf() : int formats with int values ***
53
54-- Iteration 1 --
550
56int(1)
57
58-- Iteration 2 --
59-1 1
60int(4)
61
62-- Iteration 3 --
632147483647 2147483640 -2147483640
64int(33)
65
66-- Iteration 4 --
67    123456 12345678   -1234567 1234567
68int(38)
69
70-- Iteration 5 --
71111 2222 333333 44444444
72int(24)
73
74-- Iteration 6 --
754667 4011 83 10
76int(15)
77
78-- Iteration 7 --
79%-5678
80int(6)
81
82-- Iteration 8 --
831 2 3 4
84int(7)
85