function Lookup($exptidx) { global $experiment_cache; $args = func_get_args(); # Look in cache first if (array_key_exists("{$exptidx}", $experiment_cache)) { return $experiment_cache["{$exptidx}"]; } $foo = new Experiment($exptidx); if ($foo->IsValid()) { # Insert into cache. $experiment_cache["{$exptidx}"] =& $foo; return $foo; } # Try lookup with pid,eid. if (count($args) == 2) { $pid = array_shift($args); $eid = array_shift($args); $foo = Experiment::LookupByPidEid($pid, $eid); # Already in the cache from LookupByPidEid() so just return it. if ($foo && $foo->IsValid()) { return $foo; } } return null; }