3v4l.org

run code in 300+ PHP versions simultaneously
<?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);
Output for 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Deprecated: Exception::__construct(): Passing null to parameter #1 ($message) of type string is deprecated in /in/lMDgd on line 27 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 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, 8.0.0 - 8.0.30
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.5.0 - 5.5.38, 5.6.0 - 5.6.40
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.

preferences:
283.67 ms | 402 KiB | 326 Q