3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class MyException extends Exception { public function __construct($message, $code=0, Exception $previous = null) { parent::__construct($message,$code,this); } public function __toString() { return __CLASS__. ":[{$this->code}]:{$this->message}\n"; } } throw new MyException("Foo");
based on Of6Vv
Output for 7.2.0
Warning: Use of undefined constant this - assumed 'this' (this will throw an Error in a future version of PHP) in /in/kHAGC on line 6 Fatal error: Uncaught Error: Wrong parameters for MyException([string $message [, long $code [, Throwable $previous = NULL]]]) in /in/kHAGC:6 Stack trace: #0 /in/kHAGC(6): Exception->__construct('Foo', 0, 'this') #1 /in/kHAGC(13): MyException->__construct('Foo') #2 {main} thrown in /in/kHAGC on line 6
Process exited with code 255.
Output for 7.0.0 - 7.1.10
Notice: Use of undefined constant this - assumed 'this' in /in/kHAGC on line 6 Fatal error: Uncaught Error: Wrong parameters for MyException([string $message [, long $code [, Throwable $previous = NULL]]]) in /in/kHAGC:6 Stack trace: #0 /in/kHAGC(6): Exception->__construct('Foo', 0, 'this') #1 /in/kHAGC(13): MyException->__construct('Foo') #2 {main} thrown in /in/kHAGC on line 6
Process exited with code 255.
Output for 5.3.21 - 5.6.28
Notice: Use of undefined constant this - assumed 'this' in /in/kHAGC on line 6 Fatal error: Wrong parameters for Exception([string $exception [, long $code [, Exception $previous = NULL]]]) in /in/kHAGC on line 6
Process exited with code 255.