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