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