fork download
  1. <?php
  2.  
  3. class ClA {
  4.  
  5. public $b;
  6.  
  7. public function __construct() {
  8. $this->b = new ClB($this);
  9. }
  10.  
  11. public function x() {
  12. echo "testing";
  13. }
  14. }
  15.  
  16.  
  17. class ClB {
  18.  
  19. private $a;
  20.  
  21. public function __construct($a) {
  22. $this->a = $a;
  23. }
  24.  
  25. public function c () {
  26. $this->a->x();
  27. }
  28. }
  29.  
  30. $a = new ClA();
  31.  
  32. $a->b->c();
  33.  
Success #stdin #stdout 0.02s 24448KB
stdin
Standard input is empty
stdout
testing