1--TEST-- 2Test dechex() 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 11echo "*** Testing dechex() : usage variations ***\n"; 12 13$inputs = [ 14 // int data 15/*1*/ 0, 16 1, 17 12345, 18 -2345, 19 18446744073709551615, // largest decimal 20 18446744073709551616, 21 22 // float data 23/* 7*/ 12.3456789000e10, 24 25 // boolean data 26/* 8*/ true, 27 false, 28 TRUE, 29 FALSE, 30 31 // empty data 32/*12*/ "", 33 '', 34]; 35 36// loop through each element of $inputs to check the behaviour of dechex() 37foreach ($inputs as $i => $input) { 38 $iterator = $i + 1; 39 echo "\n-- Iteration $iterator --\n"; 40 try { 41 var_dump(dechex($input)); 42 } catch (TypeError $exception) { 43 echo $exception->getMessage() . "\n"; 44 } 45} 46 47?> 48--EXPECT-- 49*** Testing dechex() : usage variations *** 50 51-- Iteration 1 -- 52string(1) "0" 53 54-- Iteration 2 -- 55string(1) "1" 56 57-- Iteration 3 -- 58string(4) "3039" 59 60-- Iteration 4 -- 61string(16) "fffffffffffff6d7" 62 63-- Iteration 5 -- 64dechex(): Argument #1 ($num) must be of type int, float given 65 66-- Iteration 6 -- 67dechex(): Argument #1 ($num) must be of type int, float given 68 69-- Iteration 7 -- 70string(10) "1cbe991a08" 71 72-- Iteration 8 -- 73string(1) "1" 74 75-- Iteration 9 -- 76string(1) "0" 77 78-- Iteration 10 -- 79string(1) "1" 80 81-- Iteration 11 -- 82string(1) "0" 83 84-- Iteration 12 -- 85dechex(): Argument #1 ($num) must be of type int, string given 86 87-- Iteration 13 -- 88dechex(): Argument #1 ($num) must be of type int, string given 89