fork download
  1. <?php
  2.  
  3. class Foo {
  4. public function returnToTheBar(Bar $bar) {
  5. $bar->getFoo($this);
  6. }
  7. }
  8.  
  9. class Bar {
  10. public $foo;
  11.  
  12. public function getFoo($foo) {
  13. $this->foo = $foo;
  14. }
  15. }
  16.  
  17.  
  18. $Foo = new Foo();
  19. $Bar = new Bar();
  20.  
  21. $Foo->returnToTheBar($Bar);
  22.  
  23. var_dump($Foo);
  24.  
  25. var_dump($Bar->foo);
  26.  
Success #stdin #stdout 0.02s 52432KB
stdin
Standard input is empty
stdout
object(Foo)#1 (0) {
}
object(Foo)#1 (0) {
}