array_walk_objects.phpt 937 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. --TEST--
  2. array_walk() and objects
  3. --FILE--
  4. <?php
  5. function walk($key, $value) {
  6. var_dump($value, $key);
  7. }
  8. class test {
  9. private $var_pri = "test_private";
  10. protected $var_pro = "test_protected";
  11. public $var_pub = "test_public";
  12. }
  13. $stdclass = new stdclass;
  14. $stdclass->foo = "foo";
  15. $stdclass->bar = "bar";
  16. array_walk($stdclass, "walk");
  17. $t = new test;
  18. array_walk($t, "walk");
  19. $var = array();
  20. array_walk($var, "walk");
  21. $var = "";
  22. array_walk($var, "walk");
  23. echo "Done\n";
  24. ?>
  25. --EXPECTF--
  26. %unicode|string%(3) "foo"
  27. %unicode|string%(3) "foo"
  28. %unicode|string%(3) "bar"
  29. %unicode|string%(3) "bar"
  30. %unicode|string%(13) "%r\0%rtest%r\0%rvar_pri"
  31. %unicode|string%(12) "test_private"
  32. %unicode|string%(10) "%r\0%r*%r\0%rvar_pro"
  33. %unicode|string%(14) "test_protected"
  34. %unicode|string%(7) "var_pub"
  35. %unicode|string%(11) "test_public"
  36. Warning: array_walk() expects parameter 1 to be array, %unicode_string_optional% given in %s on line %d
  37. Done