1--TEST-- 2Test array_walk_recursive() function : object functionality 3--FILE-- 4<?php 5/* Prototype : bool array_walk_recursive(array $input, string $funcname [, mixed $userdata]) 6 * Description: Apply a user function to every member of an array 7 * Source code: ext/standard/array.c 8*/ 9 10/* Passing object in place of an 'input' argument to test object functionality 11 */ 12echo "*** Testing array_walk_recursive() : object functionality ***\n"; 13 14/* 15 * Prototype : callback(mixed $value, mixed $key, int $addvalue 16 * Parameters : $value - values in given input array 17 * $key - keys in given input array 18 * $addvalue - value to be added 19 * Description : Function adds the addvalue to each element of an array 20*/ 21 22function callback($value, $key, $user_data) 23{ 24 var_dump($key); 25 var_dump($value); 26 var_dump($user_data); 27 echo "\n"; 28} 29 30class MyClass 31{ 32 private $pri_value; 33 public $pub_value; 34 protected $pro_value; 35 public function __construct($setVal) 36 { 37 $this->pri_value = $setVal; 38 $this->pub_value = $setVal; 39 $this->pro_value = $setVal; 40 } 41}; 42 43// object for 'input' argument 44$input = new MyClass(10); 45 46var_dump( array_walk_recursive($input, "callback", 1)); 47 48echo "Done" 49?> 50--EXPECTF-- 51*** Testing array_walk_recursive() : object functionality *** 52%unicode|string%(18) "%r\0%rMyClass%r\0%rpri_value" 53int(10) 54int(1) 55 56%unicode|string%(9) "pub_value" 57int(10) 58int(1) 59 60%unicode|string%(12) "%r\0%r*%r\0%rpro_value" 61int(10) 62int(1) 63 64bool(true) 65Done 66