1--TEST--
2Test base_convert() function : usage variations - different data types as $tobase argument
3--FILE--
4<?php
5/* Prototype  : string base_convert  ( string $number  , int $frombase  , int $tobase  )
6 * Description: Convert a number between arbitrary bases.
7 * Source code: ext/standard/math.c
8 */
9
10echo "*** Testing base_convert() : usage variations ***\n";
11
12//get an unset variable
13$unset_var = 10;
14unset ($unset_var);
15
16// heredoc string
17$heredoc = <<<EOT
18abc
19xyz
20EOT;
21
22$inputs = array(
23       // int data
24/*1*/  0,
25       1,
26       -1,
27       -12,
28       2147483647,
29
30       // float data
31/*6*/  10.5,
32       -10.5,
33       1.234567e2,
34       1.234567E-2,
35       .5,
36
37       // null data
38/*11*/ NULL,
39       null,
40
41       // boolean data
42/*13*/ true,
43       false,
44       TRUE,
45       FALSE,
46
47       // empty data
48/*17*/ "",
49       '',
50       array(),
51
52       // string data
53/*20*/ "abcxyz",
54       'abcxyz',
55       $heredoc,
56
57       // undefined data
58/*23*/ @$undefined_var,
59
60       // unset data
61/*24*/ @$unset_var,
62);
63
64// loop through each element of $inputs to check the behaviour of base_convert()
65$iterator = 1;
66foreach($inputs as $input) {
67	echo "\n-- Iteration $iterator --\n";
68	var_dump(base_convert(25, 10, $input));
69	$iterator++;
70};
71?>
72===Done===
73--EXPECTF--
74*** Testing base_convert() : usage variations ***
75
76-- Iteration 1 --
77
78Warning: base_convert(): Invalid `to base' (0) in %s on line %d
79bool(false)
80
81-- Iteration 2 --
82
83Warning: base_convert(): Invalid `to base' (1) in %s on line %d
84bool(false)
85
86-- Iteration 3 --
87
88Warning: base_convert(): Invalid `to base' (-1) in %s on line %d
89bool(false)
90
91-- Iteration 4 --
92
93Warning: base_convert(): Invalid `to base' (-12) in %s on line %d
94bool(false)
95
96-- Iteration 5 --
97
98Warning: base_convert(): Invalid `to base' (2147483647) in %s on line %d
99bool(false)
100
101-- Iteration 6 --
102string(2) "25"
103
104-- Iteration 7 --
105
106Warning: base_convert(): Invalid `to base' (-10) in %s on line %d
107bool(false)
108
109-- Iteration 8 --
110
111Warning: base_convert(): Invalid `to base' (123) in %s on line %d
112bool(false)
113
114-- Iteration 9 --
115
116Warning: base_convert(): Invalid `to base' (0) in %s on line %d
117bool(false)
118
119-- Iteration 10 --
120
121Warning: base_convert(): Invalid `to base' (0) in %s on line %d
122bool(false)
123
124-- Iteration 11 --
125
126Warning: base_convert(): Invalid `to base' (0) in %s on line %d
127bool(false)
128
129-- Iteration 12 --
130
131Warning: base_convert(): Invalid `to base' (0) in %s on line %d
132bool(false)
133
134-- Iteration 13 --
135
136Warning: base_convert(): Invalid `to base' (1) in %s on line %d
137bool(false)
138
139-- Iteration 14 --
140
141Warning: base_convert(): Invalid `to base' (0) in %s on line %d
142bool(false)
143
144-- Iteration 15 --
145
146Warning: base_convert(): Invalid `to base' (1) in %s on line %d
147bool(false)
148
149-- Iteration 16 --
150
151Warning: base_convert(): Invalid `to base' (0) in %s on line %d
152bool(false)
153
154-- Iteration 17 --
155
156Warning: base_convert() expects parameter 3 to be long, string given in %s on line %d
157NULL
158
159-- Iteration 18 --
160
161Warning: base_convert() expects parameter 3 to be long, string given in %s on line %d
162NULL
163
164-- Iteration 19 --
165
166Warning: base_convert() expects parameter 3 to be long, array given in %s on line %d
167NULL
168
169-- Iteration 20 --
170
171Warning: base_convert() expects parameter 3 to be long, string given in %s on line %d
172NULL
173
174-- Iteration 21 --
175
176Warning: base_convert() expects parameter 3 to be long, string given in %s on line %d
177NULL
178
179-- Iteration 22 --
180
181Warning: base_convert() expects parameter 3 to be long, string given in %s on line %d
182NULL
183
184-- Iteration 23 --
185
186Warning: base_convert(): Invalid `to base' (0) in %s on line %d
187bool(false)
188
189-- Iteration 24 --
190
191Warning: base_convert(): Invalid `to base' (0) in %s on line %d
192bool(false)
193===Done===