1--TEST-- 2array_walk_recursive() and objects 3--FILE-- 4<?php 5 6function walk($key, $value) { 7 var_dump($value, $key); 8} 9 10class test { 11 private $var_pri = "test_private"; 12 protected $var_pro = "test_protected"; 13 public $var_pub = "test_public"; 14} 15 16$stdclass = new stdclass; 17$stdclass->foo = "foo"; 18$stdclass->bar = "bar"; 19array_walk_recursive($stdclass, "walk"); 20 21$t = new test; 22array_walk_recursive($t, "walk"); 23 24$var = array(); 25array_walk_recursive($var, "walk"); 26$var = ""; 27try { 28 array_walk_recursive($var, "walk"); 29} catch (TypeError $e) { 30 echo $e->getMessage(), "\n"; 31} 32 33echo "Done\n"; 34?> 35--EXPECTF-- 36string(3) "foo" 37string(3) "foo" 38string(3) "bar" 39string(3) "bar" 40string(13) "%0test%0var_pri" 41string(12) "test_private" 42string(10) "%0*%0var_pro" 43string(14) "test_protected" 44string(7) "var_pub" 45string(11) "test_public" 46array_walk_recursive(): Argument #1 ($array) must be of type array, string given 47Done 48