3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php namespace Foo; use Bar\B; class A { public function foo(): Closure { $b = new B(); return function() use ($b) { $b->bar(); }; } } namespace Bar; use Buzz\ImportedException; class B { public function bar() { throw new ImportedException(); } } namespace Buzz; use \Exception; class ImportedException extends Exception { } $a = new A(); $closure = $a->foo(); $closure();
based on d1TDf
Output for 7.0.30 - 7.3.0alpha1
Fatal error: Uncaught Error: Class 'Buzz\A' not found in /in/huv3k:33 Stack trace: #0 {main} thrown in /in/huv3k on line 33
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught Error: Class undefined: Buzz\A in /in/huv3k:-1 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.18.5 - 3.21.3
Fatal error: Uncaught Error: Class undefined: Buzz\A in /in/huv3k:33 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.30
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/huv3k on line 7
Process exited with code 255.