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