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 != 8) die("skip this test is for 64bit platform only");
8?>
9--FILE--
10<?php
11/* Prototype  : number hexdec  ( string $hex_string  )
12 * Description: Returns the decimal equivalent of the hexadecimal number represented by the hex_string  argument.
13 * Source code: ext/standard/math.c
14 */
15
16echo "*** Testing hexdec() : usage variations ***\n";
17//get an unset variable
18$unset_var = 10;
19unset ($unset_var);
20
21// heredoc string
22$heredoc = <<<EOT
23abc
24xyz
25EOT;
26
27// get a resource variable
28$fp = fopen(__FILE__, "r");
29
30$inputs = array(
31       // int data
32/*1*/  0,
33       1,
34       12345,
35       -2345,
36       4294967295,  // largest decimal
37       4294967296,
38
39       // float data
40/*7*/  10.5,
41       -10.5,
42       12.3456789000e10,
43       12.3456789000E-10,
44       .5,
45
46       // null data
47/*12*/ NULL,
48       null,
49
50       // boolean data
51/*14*/ true,
52       false,
53       TRUE,
54       FALSE,
55
56       // empty data
57/*18*/ "",
58       '',
59       array(),
60
61       // string data
62/*21*/ "abcxyz",
63       'abcxyz',
64       $heredoc,
65
66       // undefined data
67/*24*/ @$undefined_var,
68
69       // unset data
70/*25*/ @$unset_var,
71
72       // resource variable
73/*26*/ $fp
74);
75
76// loop through each element of $inputs to check the behaviour of hexdec()
77$iterator = 1;
78foreach($inputs as $input) {
79	echo "\n-- Iteration $iterator --\n";
80	var_dump(hexdec($input));
81	$iterator++;
82};
83fclose($fp);
84?>
85===Done===
86--EXPECTF--
87*** Testing hexdec() : usage variations ***
88
89-- Iteration 1 --
90int(0)
91
92-- Iteration 2 --
93int(1)
94
95-- Iteration 3 --
96int(74565)
97
98-- Iteration 4 --
99int(9029)
100
101-- Iteration 5 --
102int(285960729237)
103
104-- Iteration 6 --
105int(285960729238)
106
107-- Iteration 7 --
108int(261)
109
110-- Iteration 8 --
111int(261)
112
113-- Iteration 9 --
114int(20015998341120)
115
116-- Iteration 10 --
117int(1250999896553)
118
119-- Iteration 11 --
120int(5)
121
122-- Iteration 12 --
123int(0)
124
125-- Iteration 13 --
126int(0)
127
128-- Iteration 14 --
129int(1)
130
131-- Iteration 15 --
132int(0)
133
134-- Iteration 16 --
135int(1)
136
137-- Iteration 17 --
138int(0)
139
140-- Iteration 18 --
141int(0)
142
143-- Iteration 19 --
144int(0)
145
146-- Iteration 20 --
147
148Notice: Array to string conversion in %s on line %d
149int(170)
150
151-- Iteration 21 --
152int(2748)
153
154-- Iteration 22 --
155int(2748)
156
157-- Iteration 23 --
158int(2748)
159
160-- Iteration 24 --
161int(0)
162
163-- Iteration 25 --
164int(0)
165
166-- Iteration 26 --
167%s
168===Done===