1--TEST-- 2Test array_map() function : usage variations - failing built-in functions & language constructs 3--FILE-- 4<?php 5/* 6 * Test array_map() by passing non-permmited built-in functions and language constructs i.e. 7 * echo(), array(), empty(), eval(), exit(), isset(), list(), print() 8 */ 9 10echo "*** Testing array_map() : non-permmited built-in functions ***\n"; 11 12// array to be passed as arguments 13$arr1 = array(1, 2); 14 15// built-in functions & language constructs 16$callback_names = array( 17/*1*/ 'echo', 18 'array', 19 'empty', 20/*4*/ 'eval', 21 'exit', 22 'isset', 23 'list', 24/*8*/ 'print' 25); 26for($count = 0; $count < count($callback_names); $count++) 27{ 28 echo "-- Iteration ".($count + 1)." --\n"; 29 try { 30 var_dump( array_map($callback_names[$count], $arr1) ); 31 } catch (TypeError $e) { 32 echo $e->getMessage(), "\n"; 33 } 34} 35 36echo "Done"; 37?> 38--EXPECT-- 39*** Testing array_map() : non-permmited built-in functions *** 40-- Iteration 1 -- 41array_map(): Argument #1 ($callback) must be a valid callback or null, function "echo" not found or invalid function name 42-- Iteration 2 -- 43array_map(): Argument #1 ($callback) must be a valid callback or null, function "array" not found or invalid function name 44-- Iteration 3 -- 45array_map(): Argument #1 ($callback) must be a valid callback or null, function "empty" not found or invalid function name 46-- Iteration 4 -- 47array_map(): Argument #1 ($callback) must be a valid callback or null, function "eval" not found or invalid function name 48-- Iteration 5 -- 49array_map(): Argument #1 ($callback) must be a valid callback or null, function "exit" not found or invalid function name 50-- Iteration 6 -- 51array_map(): Argument #1 ($callback) must be a valid callback or null, function "isset" not found or invalid function name 52-- Iteration 7 -- 53array_map(): Argument #1 ($callback) must be a valid callback or null, function "list" not found or invalid function name 54-- Iteration 8 -- 55array_map(): Argument #1 ($callback) must be a valid callback or null, function "print" not found or invalid function name 56Done 57