fork(1) download
  1. <?php
  2. class Foo {
  3. public function bar($baz) {
  4. return 'I am bar from Foo and I know that baz is: '.$baz;
  5. }
  6. }
  7.  
  8. class Bar {
  9. private $foo = null;
  10.  
  11. public function callBar($baz) {
  12. return $this->foo->bar($baz);
  13. }
  14.  
  15. public function __construct(Foo $foo) {
  16. $this->foo = $foo;
  17. }
  18. }
  19.  
  20. $foo = new Foo();
  21. $bar = new Bar($foo);
  22. echo $bar->callBar(10);
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
I am bar from Foo and I know that baz is: 10