3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function creator($var) { return new class($var) { private static $var; function __construct($var) { static::$var = $var; } function __debugInfo() { return [ "\0*\0var" => static::$var, ]; } }; } $a = creator('A'); $b = creator('B'); var_dump($a, $b, $a === $b);
Output for 7.0.0 - 7.2.6
object(class@anonymous)#1 (1) { ["var":protected]=> string(1) "B" } object(class@anonymous)#2 (1) { ["var":protected]=> string(1) "B" } bool(false)
Output for hhvm-3.21.3 - 3.22.0
object(class@anonymous$creator;4)#1 (1) { ["var":protected]=> string(1) "B" } object(class@anonymous$creator;4)#2 (1) { ["var":protected]=> string(1) "B" } bool(false)
Output for hhvm-3.18.5
object(class@anonymous$creator;2)#1 (1) { ["var":protected]=> string(1) "B" } object(class@anonymous$creator;2)#2 (1) { ["var":protected]=> string(1) "B" } bool(false)
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/vLjTI on line 5
Process exited with code 255.