All pastes #450720 Raw Edit

Stuff

public text v1 · immutable
·published 2007-04-21 01:47 UTC
rendered paste body
/* Main php: */
__autoload('shop');

/**
 * Start session
 */
session_start();
if (isset($_GET['destroy'])) {
  session_destroy();
  session_start();
}

print_r(shop::singleton());
exit();

/* class snippet */
class shop {
  public static function singleton() {
    if (self::$_instance === null) {
      if (isset($_SESSION['shop'])) {
        self::$_instance = $_SESSION['shop'];
      } else {
        self::$_instance = new shop();
        self::$_instance->load();

        $_SESSION['shop'] = self::$_instance;
      }
    }

    self::$_instance->setDefines();
    return self::$_instance;
  }
}