1--TEST--
2Test quoted_printable_decode() function : usage variations - unexpected values for 'str' argument
3--FILE--
4<?php
5/* Prototype  : string quoted_printable_decode  ( string $str  )
6 * Description: Convert a quoted-printable string to an 8 bit string
7 * Source code: ext/standard/string.c
8*/
9
10/*
11* Testing quoted_printable_decode() : with different unexpected values for format argument other than the strings
12*/
13
14echo "*** Testing quoted_printable_decode() : with unexpected values for 'str' argument ***\n";
15
16// initialing required variables
17$arg1 = "second arg";
18$arg2 = "third arg";
19
20//get an unset variable
21$unset_var = 10;
22unset ($unset_var);
23
24// declaring class
25class sample
26{
27  public function __toString() {
28    return "Object";
29  }
30}
31
32// creating a file resource
33$file_handle = fopen(__FILE__, 'r');
34
35//array of values to iterate over
36$values = array(
37
38      		  // int data
39/*1*/	      0,
40		      1,
41		      12345,
42		      -2345,
43
44		      // float data
45/*5*/	      10.5,
46		      -10.5,
47		      10.1234567e10,
48		      10.7654321E-10,
49		      .5,
50
51		      // array data
52/*10*/	      array(),
53		      array(0),
54		      array(1),
55		      array(1, 2),
56		      array('color' => 'red', 'item' => 'pen'),
57
58		      // null data
59/*15*/	      NULL,
60		      null,
61
62		      // boolean data
63/*17*/	      true,
64		      false,
65		      TRUE,
66		      FALSE,
67
68		      // empty data
69/*21*/	      "",
70		      '',
71
72		      // object data
73/*23*/	      new sample(),
74
75		      // undefined data
76/*24*/	      @$undefined_var,
77
78		      // unset data
79/*25*/	      @$unset_var,
80
81		      // resource data
82/*26*/	      $file_handle
83);
84
85// loop through each element of the array for 'str'
86
87$count = 1;
88foreach($values as $value) {
89  echo "\n-- Iteration $count --\n";
90  var_dump(bin2hex(quoted_printable_decode($value)));
91  $count++;
92};
93
94// close the resource
95fclose($file_handle);
96
97?>
98===DONE===
99--EXPECTF--
100*** Testing quoted_printable_decode() : with unexpected values for 'str' argument ***
101
102-- Iteration 1 --
103string(2) "30"
104
105-- Iteration 2 --
106string(2) "31"
107
108-- Iteration 3 --
109string(10) "3132333435"
110
111-- Iteration 4 --
112string(10) "2d32333435"
113
114-- Iteration 5 --
115string(8) "31302e35"
116
117-- Iteration 6 --
118string(10) "2d31302e35"
119
120-- Iteration 7 --
121string(24) "313031323334353637303030"
122
123-- Iteration 8 --
124string(26) "312e3037363534333231452d39"
125
126-- Iteration 9 --
127string(6) "302e35"
128
129-- Iteration 10 --
130
131Warning: quoted_printable_decode() expects parameter 1 to be string, array given in %s on line %d
132string(0) ""
133
134-- Iteration 11 --
135
136Warning: quoted_printable_decode() expects parameter 1 to be string, array given in %s on line %d
137string(0) ""
138
139-- Iteration 12 --
140
141Warning: quoted_printable_decode() expects parameter 1 to be string, array given in %s on line %d
142string(0) ""
143
144-- Iteration 13 --
145
146Warning: quoted_printable_decode() expects parameter 1 to be string, array given in %s on line %d
147string(0) ""
148
149-- Iteration 14 --
150
151Warning: quoted_printable_decode() expects parameter 1 to be string, array given in %s on line %d
152string(0) ""
153
154-- Iteration 15 --
155string(0) ""
156
157-- Iteration 16 --
158string(0) ""
159
160-- Iteration 17 --
161string(2) "31"
162
163-- Iteration 18 --
164string(0) ""
165
166-- Iteration 19 --
167string(2) "31"
168
169-- Iteration 20 --
170string(0) ""
171
172-- Iteration 21 --
173string(0) ""
174
175-- Iteration 22 --
176string(0) ""
177
178-- Iteration 23 --
179string(12) "4f626a656374"
180
181-- Iteration 24 --
182string(0) ""
183
184-- Iteration 25 --
185string(0) ""
186
187-- Iteration 26 --
188
189Warning: quoted_printable_decode() expects parameter 1 to be string, resource given in %s on line %d
190string(0) ""
191===DONE===
192