3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ThrowsError { public $name = 'unnamed'; public function __construct($name) { $this->name = $name; throw new \Exception("I blew up the constructor of '$name'"); } } $emptyVar = null; $obj = (object)array('number' => 1); try { $emptyVar = new ThrowsError('emptyVar'); } catch (\Exception $e) { print($e->getMessage()); } try { $obj = new ThrowsError('obj'); } catch (\Exception $e) { print($e->getMessage()); } var_dump($emptyVar); var_dump($obj);

preferences:
39.14 ms | 402 KiB | 5 Q