1--TEST--
2Test vprintf() function : usage variations - char formats with char values
3--FILE--
4<?php
5
6/*
7* Test vprintf() for char formats with an array of chars passed to the function
8*/
9
10echo "*** Testing vprintf() : char formats with char values ***\n";
11
12
13// defining array of char formats
14$formats = array(
15  "%c",
16  "%+c %-c",
17  "%lc %4c %-4c",
18  "%10.4c %-10.4c %04c %04.4c",
19  "%'#2c %'2c %'$2c %'_2c",
20  "%c %c %c %c",
21  "% %%c",
22  '%3$c %4$c %1$c %2$c'
23);
24
25// Arrays of char values for the format defined in $format.
26// Each sub array contains char values which correspond to each format string in $format
27$args_array = array(
28  array(0),
29  array('c', 67),
30  array(' ', -67, +67),
31  array(97, -97, 98, +98),
32  array(97, -97, 98, +98),
33  array(0x123b, 0xfAb, 0123, 012),
34  array(38, -1234),
35  array(67, 68, 65, 66)
36
37);
38
39// looping to test vprintf() with different char formats from the above $format array
40// and with char 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--EXPECTF--
52*** Testing vprintf() : char formats with char values ***
53
54-- Iteration 1 --
55%0
56int(1)
57
58-- Iteration 2 --
59%0 C
60int(3)
61
62-- Iteration 3 --
63%0 � C
64int(5)
65
66-- Iteration 4 --
67a � b b
68int(7)
69
70-- Iteration 5 --
71a � b b
72int(7)
73
74-- Iteration 6 --
75; � S
76
77int(7)
78
79-- Iteration 7 --
80%.
81int(2)
82
83-- Iteration 8 --
84A B C D
85int(7)
86