3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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) . ';');
based on ppk2I
Output for 7.0.2 - 7.2.0
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.3.19 - 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.