fork download
  1. <?php
  2.  
  3. $test = new A();
  4.  
  5. class A
  6. {
  7. public function __construct () {
  8. try{
  9. throw new B($this);
  10. }
  11. catch (B $e) {
  12. $e->bar();
  13. }
  14. }
  15. public function foo($arg){
  16. echo "Finally we are in foo(). Message: ".$arg;
  17. }
  18. }
  19.  
  20. class B extends Exception
  21. {
  22. public $arg;
  23. public function __construct ($arg) {
  24. $this->arg = $arg;
  25. }
  26. public function bar(){
  27. $this->arg->foo("hey");
  28. }
  29. }
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
Finally we are in foo(). Message: hey