Ok, I’m trying to do something similar to Singleton (http://www.php.net/manual/en/language.oop5.patterns.php), but keep a list of multiple instances, one for each $user.
I’ve tried about a million different versions of this, but I keep getting an error:
Line 197 being the function definition, of course.
class Conversations {
var $instances;
public static function getConvo ($user) {
sEcho('getConvo called for user '.$user.'; ');
foreach (self::$instances as $instance) {
sEcho('Instance: ');
}
// Call statically to get user convo
if (self::$instances[$user]) {
sEcho('Instance exists. Returning '.$user);
return self::$instances[$user];
} else {
sEcho('Creating new Conversation for '.$user);
self::$instances[$user] = new Conversation($user);
//sEcho(print_r($instances));
return self::$instances[$user];
}
}
}
Please help, since I’d like to finish this as quickly as possible. Hopefully before my friend and I go to bed.
Thanks ![]()