1--TEST--
2Test bindec() function : usage variations - different data types as $binary_string arg
3--SKIPIF--
4<?php
5if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
6?>
7--FILE--
8<?php
9echo "*** Testing bindec() : usage variations ***\n";
10//get an unset variable
11$unset_var = 10;
12unset ($unset_var);
13
14// heredoc string
15$heredoc = <<<EOT
16abc
17xyz
18EOT;
19
20// get a resource variable
21$fp = fopen(__FILE__, "r");
22
23$inputs = array(
24       // int data
25/*1*/  0,
26       1,
27       12345,
28       -2345,
29
30       // float data
31/*5*/  10.5,
32       -10.5,
33       12.3456789000e10,
34       12.3456789000E-10,
35       .5,
36
37       // null data
38/*10*/ NULL,
39       null,
40
41       // boolean data
42/*12*/ true,
43       false,
44       TRUE,
45       FALSE,
46
47       // empty data
48/*16*/ "",
49       '',
50       array(),
51
52       // string data
53/*19*/ "abcxyz",
54       'abcxyz',
55       $heredoc,
56
57       // undefined data
58/*22*/ @$undefined_var,
59
60       // unset data
61/*23*/ @$unset_var,
62
63       // resource variable
64/*24*/ $fp
65);
66
67// loop through each element of $inputs to check the behaviour of bindec()
68$iterator = 1;
69foreach($inputs as $input) {
70    echo "\n-- Iteration $iterator --\n";
71    try {
72        var_dump(bindec($input));
73    } catch (TypeError $e) {
74        echo $e->getMessage(), "\n";
75    }
76    $iterator++;
77};
78fclose($fp);
79?>
80--EXPECTF--
81*** Testing bindec() : usage variations ***
82
83-- Iteration 1 --
84int(0)
85
86-- Iteration 2 --
87int(1)
88
89-- Iteration 3 --
90
91Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
92int(1)
93
94-- Iteration 4 --
95
96Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
97int(0)
98
99-- Iteration 5 --
100
101Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
102int(2)
103
104-- Iteration 6 --
105
106Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
107int(2)
108
109-- Iteration 7 --
110
111Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
112int(8)
113
114-- Iteration 8 --
115
116Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
117int(1)
118
119-- Iteration 9 --
120
121Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
122int(0)
123
124-- Iteration 10 --
125int(0)
126
127-- Iteration 11 --
128int(0)
129
130-- Iteration 12 --
131int(1)
132
133-- Iteration 13 --
134int(0)
135
136-- Iteration 14 --
137int(1)
138
139-- Iteration 15 --
140int(0)
141
142-- Iteration 16 --
143int(0)
144
145-- Iteration 17 --
146int(0)
147
148-- Iteration 18 --
149bindec(): Argument #1 ($binary_string) must be of type string, array given
150
151-- Iteration 19 --
152
153Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
154int(0)
155
156-- Iteration 20 --
157
158Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
159int(0)
160
161-- Iteration 21 --
162
163Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
164int(0)
165
166-- Iteration 22 --
167int(0)
168
169-- Iteration 23 --
170int(0)
171
172-- Iteration 24 --
173bindec(): Argument #1 ($binary_string) must be of type string, resource given
174