1--TEST-- 2Test array_map() function : usage variations - built-in function as callback 3--FILE-- 4<?php 5/* 6 * Test array_map() by passing buit-in function as callback function 7 */ 8 9echo "*** Testing array_map() : built-in function ***\n"; 10 11$array1 = array(1, 2, 3); 12$array2 = array(3, 4, 5); 13 14echo "-- with built-in function 'pow' and two parameters --\n"; 15var_dump( array_map('pow', $array1, $array2)); 16 17echo "-- with built-in function 'pow' and one parameter --\n"; 18try { 19 var_dump( array_map('pow', $array1)); 20} catch (TypeError $e) { 21 echo $e->getMessage(), "\n"; 22} 23 24echo "-- with language construct --\n"; 25try { 26 var_dump( array_map('echo', $array1)); 27} catch (TypeError $e) { 28 echo $e->getMessage(), "\n"; 29} 30 31echo "Done"; 32?> 33--EXPECT-- 34*** Testing array_map() : built-in function *** 35-- with built-in function 'pow' and two parameters -- 36array(3) { 37 [0]=> 38 int(1) 39 [1]=> 40 int(16) 41 [2]=> 42 int(243) 43} 44-- with built-in function 'pow' and one parameter -- 45pow() expects exactly 2 arguments, 1 given 46-- with language construct -- 47array_map(): Argument #1 ($callback) must be a valid callback or null, function "echo" not found or invalid function name 48Done 49