3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Server { private $hostname; private $cpu; private $ram; public function __construct($hostname = "", $cpu = "", $ram = 0) { $this->hostname = $hostname; $this->cpu = $cpu; $this->ram = $ram; } public function getHostname() { return $this->hostname; } public function setHostname($hostname) { return $this->hostname = ($hostname === null ? $this->_exception() : $hostname); } protected function _exception($text = null) { throw new InvalidArgumentException($text); } } $server = new Server; $server->setHostname(null);
based on 2nUce
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught InvalidArgumentException in /in/lMDgd:27 Stack trace: #0 /in/lMDgd(22): Server->_exception() #1 /in/lMDgd(31): Server->setHostname(NULL) #2 {main} thrown in /in/lMDgd on line 27
Process exited with code 255.
Output for 5.3.20 - 5.6.28
Fatal error: Uncaught exception 'InvalidArgumentException' in /in/lMDgd:27 Stack trace: #0 /in/lMDgd(22): Server->_exception() #1 /in/lMDgd(31): Server->setHostname(NULL) #2 {main} thrown in /in/lMDgd on line 27
Process exited with code 255.