bug34893.phpt 535 B

123456789101112131415161718192021222324252627282930313233
  1. --TEST--
  2. Bug #34893 (PHP5.1 overloading, Cannot access private property)
  3. --FILE--
  4. <?php
  5. class A {
  6. private $p;
  7. function __get($name){
  8. return $this->$name;
  9. }
  10. function __set($name, $value) {
  11. $this->$name = $value;
  12. }
  13. }
  14. class B {
  15. private $t;
  16. function __get($name){
  17. return $this->$name;
  18. }
  19. function __set($name, $value) {
  20. $this->$name = $value;
  21. }
  22. }
  23. $a = new A;
  24. $b = new B;
  25. $a->p = $b;
  26. $b->t = "foo";
  27. echo $a->p->t;
  28. $a->p->t = "bar";
  29. echo $a->p->t;
  30. ?>
  31. --EXPECT--
  32. foobar