1--TEST--
2Test vprintf() function : usage variations - unexpected values for args argument
3--FILE--
4<?php
5/* Prototype  : string vprintf(string format, array args)
6 * Description: Output a formatted string
7 * Source code: ext/standard/formatted_print.c
8*/
9
10/*
11 * Test vprintf() when different unexpected values are passed to
12 * the '$args' arguments of the function
13*/
14
15echo "*** Testing vprintf() : with unexpected values for args argument ***\n";
16
17// initialising the required variables
18$format = '%s';
19
20//get an unset variable
21$unset_var = 10;
22unset ($unset_var);
23
24// declaring a class
25class sample
26{
27  public function __toString() {
28  return "object";
29  }
30}
31
32// Defining resource
33$file_handle = fopen(__FILE__, 'r');
34
35
36//array of values to iterate over
37$values = array(
38
39		  // int data
40/*1*/	  0,
41		  1,
42		  12345,
43		  -2345,
44
45		  // float data
46/*5*/	  10.5,
47		  -10.5,
48		  10.1234567e10,
49		  10.7654321E-10,
50		  .5,
51
52		  // null data
53/*10*/	  NULL,
54		  null,
55
56		  // boolean data
57/*12*/	  true,
58		  false,
59		  TRUE,
60		  FALSE,
61
62		  // empty data
63/*16*/	  "",
64		  '',
65
66		  // string data
67/*18*/	  "string",
68		  'string',
69
70		  // object data
71/*20*/	  new sample(),
72
73		  // undefined data
74/*21*/	  @$undefined_var,
75
76		  // unset data
77/*22*/	  @$unset_var,
78
79		  // resource data
80/*23*/		  $file_handle
81);
82
83// loop through each element of the array for args
84$counter = 1;
85foreach($values as $value) {
86  echo "\n-- Iteration $counter --\n";
87  $result = vprintf($format,$value);
88  echo "\n";
89  var_dump($result);
90  $counter++;
91};
92
93// closing the resource
94fclose($file_handle);
95
96?>
97===DONE===
98--EXPECTF--
99*** Testing vprintf() : with unexpected values for args argument ***
100
101-- Iteration 1 --
1020
103int(1)
104
105-- Iteration 2 --
1061
107int(1)
108
109-- Iteration 3 --
11012345
111int(5)
112
113-- Iteration 4 --
114-2345
115int(5)
116
117-- Iteration 5 --
11810.5
119int(4)
120
121-- Iteration 6 --
122-10.5
123int(5)
124
125-- Iteration 7 --
126101234567000
127int(12)
128
129-- Iteration 8 --
1301.07654321E-9
131int(13)
132
133-- Iteration 9 --
1340.5
135int(3)
136
137-- Iteration 10 --
138
139Warning: vprintf(): Too few arguments in %s on line %d
140
141bool(false)
142
143-- Iteration 11 --
144
145Warning: vprintf(): Too few arguments in %s on line %d
146
147bool(false)
148
149-- Iteration 12 --
1501
151int(1)
152
153-- Iteration 13 --
154
155int(0)
156
157-- Iteration 14 --
1581
159int(1)
160
161-- Iteration 15 --
162
163int(0)
164
165-- Iteration 16 --
166
167int(0)
168
169-- Iteration 17 --
170
171int(0)
172
173-- Iteration 18 --
174string
175int(6)
176
177-- Iteration 19 --
178string
179int(6)
180
181-- Iteration 20 --
182
183Warning: vprintf(): Too few arguments in %s on line %d
184
185bool(false)
186
187-- Iteration 21 --
188
189Warning: vprintf(): Too few arguments in %s on line %d
190
191bool(false)
192
193-- Iteration 22 --
194
195Warning: vprintf(): Too few arguments in %s on line %d
196
197bool(false)
198
199-- Iteration 23 --
200Resource id #%d
201int(%d)
202===DONE===
203