1--TEST--
2Test base_convert() function : usage variations - different data types as $number 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// get a resource variable
23$fp = fopen(__FILE__, "r");
24
25$inputs = array(
26       // int data
27/*1*/  0,
28       1,
29       12,
30       -12,
31       2147483647,
32
33       // float data
34/*6*/  10.5,
35       -10.5,
36       1.234567e2,
37       1.234567E-2,
38       .5,
39
40       // null data
41/*11*/ NULL,
42       null,
43
44       // boolean data
45/*13*/ true,
46       false,
47       TRUE,
48       FALSE,
49
50       // empty data
51/*17*/ "",
52       '',
53       array(),
54
55       // string data
56/*20*/ "abcxyz",
57       'abcxyz',
58       $heredoc,
59
60       // undefined data
61/*23*/ @$undefined_var,
62
63       // unset data
64/*24*/ @$unset_var,
65
66       // resource variable
67/*25*/ $fp
68);
69
70// loop through each element of $inputs to check the behaviour of base_convert()
71$iterator = 1;
72foreach($inputs as $input) {
73	echo "\n-- Iteration $iterator --\n";
74	var_dump(base_convert($input, 10, 8));
75	$iterator++;
76};
77fclose($fp);
78?>
79===Done===
80--EXPECTF--
81*** Testing base_convert() : usage variations ***
82
83-- Iteration 1 --
84string(1) "0"
85
86-- Iteration 2 --
87string(1) "1"
88
89-- Iteration 3 --
90string(2) "14"
91
92-- Iteration 4 --
93string(2) "14"
94
95-- Iteration 5 --
96string(11) "17777777777"
97
98-- Iteration 6 --
99string(3) "151"
100
101-- Iteration 7 --
102string(3) "151"
103
104-- Iteration 8 --
105string(7) "4553207"
106
107-- Iteration 9 --
108string(7) "4553207"
109
110-- Iteration 10 --
111string(1) "5"
112
113-- Iteration 11 --
114string(1) "0"
115
116-- Iteration 12 --
117string(1) "0"
118
119-- Iteration 13 --
120string(1) "1"
121
122-- Iteration 14 --
123string(1) "0"
124
125-- Iteration 15 --
126string(1) "1"
127
128-- Iteration 16 --
129string(1) "0"
130
131-- Iteration 17 --
132string(1) "0"
133
134-- Iteration 18 --
135string(1) "0"
136
137-- Iteration 19 --
138
139Notice: Array to string conversion in %s on line %d
140string(1) "0"
141
142-- Iteration 20 --
143string(1) "0"
144
145-- Iteration 21 --
146string(1) "0"
147
148-- Iteration 22 --
149string(1) "0"
150
151-- Iteration 23 --
152string(1) "0"
153
154-- Iteration 24 --
155string(1) "0"
156
157-- Iteration 25 --
158string(%d) "%d"
159===Done===
160