1--TEST-- 2Test chr() function : usage variations - test values for $ascii argument 3--FILE-- 4<?php 5 6echo "*** Testing chr() function: with unexpected inputs for 'ascii' argument ***\n"; 7 8//defining a class 9class sample { 10 public function __toString() { 11 return "sample object"; 12 } 13} 14 15//getting the resource 16$file_handle = fopen(__FILE__, "r"); 17 18// array with different values for $input 19$inputs = array ( 20 21 // integer values 22/*1*/ 0, 23 1, 24 255, 25 256, 26 27 // float values 28/*5*/ 10.5, 29 -20.5, 30 1.1234e6, 31 32 // boolean values 33/*11*/ true, 34 false, 35 TRUE, 36 FALSE, 37); 38 39// loop through with each element of the $inputs array to test chr() function 40$count = 1; 41foreach($inputs as $input) { 42 echo "-- Iteration $count --\n"; 43 var_dump( bin2hex(chr($input)) ); 44 $count ++; 45} 46 47fclose($file_handle); //closing the file handle 48 49?> 50--EXPECTF-- 51*** Testing chr() function: with unexpected inputs for 'ascii' argument *** 52-- Iteration 1 -- 53string(2) "00" 54-- Iteration 2 -- 55string(2) "01" 56-- Iteration 3 -- 57string(2) "ff" 58-- Iteration 4 -- 59string(2) "00" 60-- Iteration 5 -- 61 62Deprecated: Implicit conversion from float 10.5 to int loses precision in %s on line %d 63string(2) "0a" 64-- Iteration 6 -- 65 66Deprecated: Implicit conversion from float -20.5 to int loses precision in %s on line %d 67string(2) "ec" 68-- Iteration 7 -- 69string(2) "48" 70-- Iteration 8 -- 71string(2) "01" 72-- Iteration 9 -- 73string(2) "00" 74-- Iteration 10 -- 75string(2) "01" 76-- Iteration 11 -- 77string(2) "00" 78