fork download
  1. <?php
  2.  
  3. class foo{
  4. public $a; //bar
  5.  
  6. function __construct(bar $a)
  7. {
  8. $this->a = $a;
  9. }
  10.  
  11.  
  12. public function scream(){
  13. echo "scream";
  14. }
  15. }
  16.  
  17. class bar {
  18. public function tryToScream()
  19. {
  20. ///?????? Is it a way to call foo->scream() from here ?????
  21. }
  22. }
  23.  
  24. $f = new foo(new bar());
  25. $f->a->tryToScream();
  26.  
Success #stdin #stdout 0.03s 52480KB
stdin
Standard input is empty
stdout
Standard output is empty