1--TEST-- 2Test array_map() function : usage variations - binary safe checking 3--FILE-- 4<?php 5/* 6 * Test array_map() by passing array having binary values for $arr1 argument 7 */ 8 9echo "*** Testing array_map() : array with binary data for 'arr1' argument ***\n"; 10 11function callback1($a) 12{ 13 return ($a); 14} 15function callback2($a, $b) 16{ 17 return array($a => $b); 18} 19 20// array with binary data 21$arr1 = array(b"hello", b"world", "1", b"22.22"); 22 23echo "-- checking binary safe array with one parameter callback function --\n"; 24var_dump( array_map('callback1', $arr1) ); 25 26echo "-- checking binary safe array with two parameter callback function --\n"; 27try { 28 var_dump( array_map(b"callback2", $arr1) ); 29} catch (Throwable $e) { 30 echo "Exception: " . $e->getMessage() . "\n"; 31} 32 33echo "Done"; 34?> 35--EXPECT-- 36*** Testing array_map() : array with binary data for 'arr1' argument *** 37-- checking binary safe array with one parameter callback function -- 38array(4) { 39 [0]=> 40 string(5) "hello" 41 [1]=> 42 string(5) "world" 43 [2]=> 44 string(1) "1" 45 [3]=> 46 string(5) "22.22" 47} 48-- checking binary safe array with two parameter callback function -- 49Exception: Too few arguments to function callback2(), 1 passed and exactly 2 expected 50Done 51