3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $foo = <<<PHP const LOST_CONSTANT_BEFORE = 42; class Foo { public function foo() { // throw notice about deprecated constructor } } const LOST_CONSTANT_AFTER = 42; PHP; set_error_handler(function($errno, $errstr) { throw new Exception($errstr, $errno); // convert error to exception }); try { eval($foo); } catch (Exception $e) { printf("error %d with message: %s\n", $e->getCode(), $e->getMessage()); } var_dump( class_exists('foo'), // exists! defined('LOST_CONSTANT_BEFORE'), // where is my constant defined('LOST_CONSTANT_AFTER') // where is my constant );
based on K4KhS
Output for 7.0.0 - 7.3.1
error 8192 with message: Methods with the same name as their class will not be constructors in a future version of PHP; Foo has a deprecated constructor bool(true) bool(false) bool(false)
Output for 5.5.0 - 5.6.28
bool(true) bool(true) bool(true)