3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class MyClass { public function __construct($id) { if (isset(self::$cache[$id])) return self::$cache[$id]; // Do expensive setup self::$cache[$id] = $this; } private static $cache = array(); } $a = new MyClass(1); $b = new MyClass(1);
based on h1Uha
Output for 5.3.21 - 7.3.0beta1