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 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 -- 99 100Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d 101int(9029) 102 103-- Iteration 5 -- 104float(285960729237) 105 106-- Iteration 6 -- 107float(285960729238) 108 109-- Iteration 7 -- 110 111Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d 112int(261) 113 114-- Iteration 8 -- 115 116Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d 117int(261) 118 119-- Iteration 9 -- 120float(20015998341120) 121 122-- Iteration 10 -- 123 124Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d 125float(1250999896553) 126 127-- Iteration 11 -- 128 129Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d 130int(5) 131 132-- Iteration 12 -- 133int(0) 134 135-- Iteration 13 -- 136int(0) 137 138-- Iteration 14 -- 139int(1) 140 141-- Iteration 15 -- 142int(0) 143 144-- Iteration 16 -- 145int(1) 146 147-- Iteration 17 -- 148int(0) 149 150-- Iteration 18 -- 151int(0) 152 153-- Iteration 19 -- 154int(0) 155 156-- Iteration 20 -- 157 158Notice: Array to string conversion in %s on line %d 159 160Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d 161int(170) 162 163-- Iteration 21 -- 164 165Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d 166int(2748) 167 168-- Iteration 22 -- 169 170Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d 171int(2748) 172 173-- Iteration 23 -- 174 175Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d 176int(2748) 177 178-- Iteration 24 -- 179int(0) 180 181-- Iteration 25 -- 182int(0) 183 184-- Iteration 26 -- 185 186Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d 187int(970453) 188===Done=== 189