<?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);
You have javascript disabled. You will not be able to edit any code.