3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types = 1); class A{ protected $stuff; function __construct($foo){ if(!is_float($foo)) throw new TypeError; $this->stuff = $foo; } static function __set_state($data){ return new A($data['stuff']); } } $x = new A(0.0); eval('$y = ' . var_export($x, true) . ';');
Output for 7.0.2 - 7.0.20, 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, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Output for 7.0.0 - 7.0.1
Fatal error: Uncaught TypeError in /in/TMaAJ:7 Stack trace: #0 /in/TMaAJ(11): A->__construct(0) #1 /in/TMaAJ(16) : eval()'d code(2): A::__set_state(Array) #2 /in/TMaAJ(16): eval() #3 {main} thrown in /in/TMaAJ on line 7
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Warning: Unsupported declare 'strict_types' in /in/TMaAJ on line 1 Fatal error: Class 'TypeError' not found in /in/TMaAJ on line 7
Process exited with code 255.

preferences:
192.69 ms | 402 KiB | 272 Q