1--TEST-- 2Test array_map() function : usage variations - failing built-in functions & language constructs 3--FILE-- 4<?php 5/* Prototype : array array_map ( callback $callback , array $arr1 [, array $... ] ) 6 * Description: Applies the callback to the elements of the given arrays 7 * Source code: ext/standard/array.c 8 */ 9 10/* 11 * Test array_map() by passing non-permmited built-in functions and language constructs i.e. 12 * echo(), array(), empty(), eval(), exit(), isset(), list(), print() 13 */ 14 15echo "*** Testing array_map() : non-permmited built-in functions ***\n"; 16 17// array to be passed as arguments 18$arr1 = array(1, 2); 19 20// built-in functions & language constructs 21$callback_names = array( 22/*1*/ 'echo', 23 'array', 24 'empty', 25/*4*/ 'eval', 26 'exit', 27 'isset', 28 'list', 29/*8*/ 'print' 30); 31for($count = 0; $count < count($callback_names); $count++) 32{ 33 echo "-- Iteration ".($count + 1)." --\n"; 34 var_dump( array_map($callback_names[$count], $arr1) ); 35} 36 37echo "Done"; 38?> 39--EXPECTF-- 40*** Testing array_map() : non-permmited built-in functions *** 41-- Iteration 1 -- 42 43Warning: array_map() expects parameter 1 to be a valid callback, function 'echo' not found or invalid function name in %s on line %d 44NULL 45-- Iteration 2 -- 46 47Warning: array_map() expects parameter 1 to be a valid callback, function 'array' not found or invalid function name in %s on line %d 48NULL 49-- Iteration 3 -- 50 51Warning: array_map() expects parameter 1 to be a valid callback, function 'empty' not found or invalid function name in %s on line %d 52NULL 53-- Iteration 4 -- 54 55Warning: array_map() expects parameter 1 to be a valid callback, function 'eval' not found or invalid function name in %s on line %d 56NULL 57-- Iteration 5 -- 58 59Warning: array_map() expects parameter 1 to be a valid callback, function 'exit' not found or invalid function name in %s on line %d 60NULL 61-- Iteration 6 -- 62 63Warning: array_map() expects parameter 1 to be a valid callback, function 'isset' not found or invalid function name in %s on line %d 64NULL 65-- Iteration 7 -- 66 67Warning: array_map() expects parameter 1 to be a valid callback, function 'list' not found or invalid function name in %s on line %d 68NULL 69-- Iteration 8 -- 70 71Warning: array_map() expects parameter 1 to be a valid callback, function 'print' not found or invalid function name in %s on line %d 72NULL 73Done 74