3v4l.org

run code in 300+ PHP versions simultaneously
<?php class FunkyException extends Exception { protected $errors = []; public function __constructor ($message, $errors) { $this->message = $message; $this->errors = $errors; parent::__construct($message); } public function getErrors() { return $this->errors; } } try { throw new FunkyException ('test', ['this','that']); } catch (FunkyException $e) { print_r ($e->getErrors()); }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Fatal error: Uncaught TypeError: Exception::__construct(): Argument #2 ($code) must be of type int, array given in /in/cgDKE:23 Stack trace: #0 /in/cgDKE(23): Exception->__construct('test', Array) #1 {main} thrown in /in/cgDKE on line 23
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught Error: Wrong parameters for FunkyException([string $message [, long $code [, Throwable $previous = NULL]]]) in /in/cgDKE:23 Stack trace: #0 /in/cgDKE(23): Exception->__construct('test', Array) #1 {main} thrown in /in/cgDKE on line 23
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Fatal error: Wrong parameters for Exception([string $exception [, long $code [, Exception $previous = NULL]]]) in /in/cgDKE on line 23
Process exited with code 255.

preferences:
209.8 ms | 401 KiB | 325 Q