array_003.phpt 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. --TEST--
  2. SPL: ArrayObject from object
  3. --FILE--
  4. <?php
  5. // This test also needs to exclude the protected and private variables
  6. // since they cannot be accessed from the external object which iterates
  7. // them.
  8. class test
  9. {
  10. public $pub = "public";
  11. protected $pro = "protected";
  12. private $pri = "private";
  13. function __construct()
  14. {
  15. $this->imp = "implicit";
  16. }
  17. };
  18. $test = new test;
  19. $test->dyn = "dynamic";
  20. print_r($test);
  21. $object = new ArrayObject($test);
  22. print_r($object);
  23. foreach($test as $key => $val)
  24. {
  25. echo "$key => $val\n";
  26. }
  27. ?>
  28. --EXPECT--
  29. test Object
  30. (
  31. [pub] => public
  32. [pro:protected] => protected
  33. [pri:test:private] => private
  34. [imp] => implicit
  35. [dyn] => dynamic
  36. )
  37. ArrayObject Object
  38. (
  39. [storage:ArrayObject:private] => test Object
  40. (
  41. [pub] => public
  42. [pro:protected] => protected
  43. [pri:test:private] => private
  44. [imp] => implicit
  45. [dyn] => dynamic
  46. )
  47. )
  48. pub => public
  49. imp => implicit
  50. dyn => dynamic