3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $class = get_class(new class { public static $count = 0; public function __construct() { self::$count++; } }); for ($i = 0; $i < 5; $i++) { $o = new $class(); } var_dump($class::$count);
based on BJMGL
Output for 7.0.0 - 7.2.0
int(6)
Output for 5.4.9 - 5.6.21
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/qkNjM on line 3
Process exited with code 255.
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected T_CLASS in /in/qkNjM on line 3
Process exited with code 255.