1--TEST--
2Test urldecode() function : usage variations  - <type here specifics of this variation>
3--FILE--
4<?php
5/* Prototype  : proto string urldecode(string str)
6 * Description: Decodes URL-encoded string
7 * Source code: ext/standard/url.c
8 * Alias to functions:
9 */
10
11// NB: basic functionality tested in tests/strings/001.phpt
12
13function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
14	echo "Error: $err_no - $err_msg, $filename($linenum)\n";
15}
16set_error_handler('test_error_handler');
17
18echo "*** Testing urldecode() : usage variations ***\n";
19
20// Initialise function arguments not being substituted (if any)
21
22//get an unset variable
23$unset_var = 10;
24unset ($unset_var);
25
26//array of values to iterate over
27$values = array(
28
29      // int data
30      0,
31      1,
32      12345,
33      -2345,
34
35      // float data
36      10.5,
37      -10.5,
38      10.1234567e10,
39      10.7654321E-10,
40      .5,
41
42      // array data
43      array(),
44      array(0),
45      array(1),
46      array(1, 2),
47      array('color' => 'red', 'item' => 'pen'),
48
49      // null data
50      NULL,
51      null,
52
53      // boolean data
54      true,
55      false,
56      TRUE,
57      FALSE,
58
59      // empty data
60      "",
61      '',
62
63      // object data
64      new stdclass(),
65
66      // undefined data
67      $undefined_var,
68
69      // unset data
70      $unset_var,
71);
72
73// loop through each element of the array for str
74
75foreach($values as $value) {
76      echo "\nArg value $value \n";
77      var_dump( urldecode($value) );
78};
79
80echo "Done";
81?>
82--EXPECTF--
83*** Testing urldecode() : usage variations ***
84Error: 8 - Undefined variable: undefined_var, %s(64)
85Error: 8 - Undefined variable: unset_var, %s(67)
86
87Arg value 0
88string(1) "0"
89
90Arg value 1
91string(1) "1"
92
93Arg value 12345
94string(5) "12345"
95
96Arg value -2345
97string(5) "-2345"
98
99Arg value 10.5
100string(4) "10.5"
101
102Arg value -10.5
103string(5) "-10.5"
104
105Arg value 101234567000
106string(12) "101234567000"
107
108Arg value 1.07654321E-9
109string(13) "1.07654321E-9"
110
111Arg value 0.5
112string(3) "0.5"
113Error: 8 - Array to string conversion, %surldecode_variation_001.php(%d)
114
115Arg value Array
116Error: 2 - urldecode() expects parameter 1 to be string, array given, %s(74)
117NULL
118Error: 8 - Array to string conversion, %surldecode_variation_001.php(%d)
119
120Arg value Array
121Error: 2 - urldecode() expects parameter 1 to be string, array given, %s(74)
122NULL
123Error: 8 - Array to string conversion, %surldecode_variation_001.php(%d)
124
125Arg value Array
126Error: 2 - urldecode() expects parameter 1 to be string, array given, %s(74)
127NULL
128Error: 8 - Array to string conversion, %surldecode_variation_001.php(%d)
129
130Arg value Array
131Error: 2 - urldecode() expects parameter 1 to be string, array given, %s(74)
132NULL
133Error: 8 - Array to string conversion, %surldecode_variation_001.php(%d)
134
135Arg value Array
136Error: 2 - urldecode() expects parameter 1 to be string, array given, %s(74)
137NULL
138
139Arg value
140string(0) ""
141
142Arg value
143string(0) ""
144
145Arg value 1
146string(1) "1"
147
148Arg value
149string(0) ""
150
151Arg value 1
152string(1) "1"
153
154Arg value
155string(0) ""
156
157Arg value
158string(0) ""
159
160Arg value
161string(0) ""
162Error: 4096 - Object of class stdClass could not be converted to string, %s(73)
163
164Arg value
165Error: 2 - urldecode() expects parameter 1 to be string, object given, %s(74)
166NULL
167
168Arg value
169string(0) ""
170
171Arg value
172string(0) ""
173Done
174