1--TEST-- 2Test dechex() function : usage variations - different data types as $num 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 dechex() : usage variations ***\n"; 12//get an unset variable 13$unset_var = 10; 14unset ($unset_var); 15 16// heredoc string 17$heredoc = <<<EOT 18abc 19xyz 20EOT; 21 22// get a class 23class classA 24{ 25} 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 // object data 67/*24*/ new classA(), 68 69 // undefined data 70/*25*/ @$undefined_var, 71 72 // unset data 73/*26*/ @$unset_var, 74 75 // resource variable 76/*27*/ $fp 77); 78 79// loop through each element of $inputs to check the behaviour of dechex() 80foreach($inputs as $i => $input) { 81 $iterator = $i + 1; 82 echo "\n-- Iteration $iterator --\n"; 83 try { 84 var_dump(dechex($input)); 85 } catch (TypeError $exception) { 86 echo $exception->getMessage() . "\n"; 87 } 88 $iterator++; 89} 90fclose($fp); 91 92?> 93--EXPECT-- 94*** Testing dechex() : usage variations *** 95 96-- Iteration 1 -- 97string(1) "0" 98 99-- Iteration 2 -- 100string(1) "1" 101 102-- Iteration 3 -- 103string(4) "3039" 104 105-- Iteration 4 -- 106string(8) "fffff6d7" 107 108-- Iteration 5 -- 109dechex(): Argument #1 ($num) must be of type int, float given 110 111-- Iteration 6 -- 112dechex(): Argument #1 ($num) must be of type int, float given 113 114-- Iteration 7 -- 115string(1) "a" 116 117-- Iteration 8 -- 118string(8) "fffffff6" 119 120-- Iteration 9 -- 121dechex(): Argument #1 ($num) must be of type int, float given 122 123-- Iteration 10 -- 124string(1) "0" 125 126-- Iteration 11 -- 127string(1) "0" 128 129-- Iteration 12 -- 130string(1) "0" 131 132-- Iteration 13 -- 133string(1) "0" 134 135-- Iteration 14 -- 136string(1) "1" 137 138-- Iteration 15 -- 139string(1) "0" 140 141-- Iteration 16 -- 142string(1) "1" 143 144-- Iteration 17 -- 145string(1) "0" 146 147-- Iteration 18 -- 148dechex(): Argument #1 ($num) must be of type int, string given 149 150-- Iteration 19 -- 151dechex(): Argument #1 ($num) must be of type int, string given 152 153-- Iteration 20 -- 154dechex(): Argument #1 ($num) must be of type int, array given 155 156-- Iteration 21 -- 157dechex(): Argument #1 ($num) must be of type int, string given 158 159-- Iteration 22 -- 160dechex(): Argument #1 ($num) must be of type int, string given 161 162-- Iteration 23 -- 163dechex(): Argument #1 ($num) must be of type int, string given 164 165-- Iteration 24 -- 166dechex(): Argument #1 ($num) must be of type int, classA given 167 168-- Iteration 25 -- 169string(1) "0" 170 171-- Iteration 26 -- 172string(1) "0" 173 174-- Iteration 27 -- 175dechex(): Argument #1 ($num) must be of type int, resource given 176