當前位置: 首頁>>代碼示例>>PHP>>正文


PHP registry::instance方法代碼示例

本文整理匯總了PHP中registry::instance方法的典型用法代碼示例。如果您正苦於以下問題:PHP registry::instance方法的具體用法?PHP registry::instance怎麽用?PHP registry::instance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在registry的用法示例。


在下文中一共展示了registry::instance方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 /**
  * Session Constructor
  *
  * The constructor runs the session routines automatically
  * whenever the class is instantiated.
  */
 public function __construct()
 {
     // Set the super object to a local variable for use throughout the class
     $this->registry =& registry::instance();
     // Do we need use cookie? If so, load the input library
     $this->registry->load->library('input');
     // Do we need encryption? If so, load the encryption library
     if ($this->session_encrypt_cookie == true) {
         $this->registry->load->library('encrypt');
     }
     // Set the "now" time.  Can either be GMT or server time, based on the
     // config prefs.  We use this to set the "last activity" time
     $this->now = $this->_get_time();
     // Set the session length. If the session expiration is
     // set to zero we'll set the expiration two years from now.
     if ($this->session_expiration == 0) {
         $this->session_expiration = 60 * 60 * 24 * 365 * 2;
     }
     // Set the cookie name
     $this->session_cookie_name = $this->cookie_prefix . $this->session_cookie_name;
     // Run the Session routine. If a session doesn't exist we'll
     // create a new one.  If it does, we'll update it.
     if (!$this->session_read()) {
         $this->session_create();
     } else {
         $this->session_update();
     }
 }
開發者ID:hymns,項目名稱:phphyppo,代碼行數:34,代碼來源:session.php

示例2: __construct

 /**
  * class constructor
  *
  * @access	public
  */
 public function __construct()
 {
     // set the class instance
     registry::instance($this);
     // instantiate loader engine
     $this->load = new AppLoader();
     // instantiate viewer engine
     $this->view = new AppViewer();
 }
開發者ID:hymns,項目名稱:phphyppo,代碼行數:14,代碼來源:AppController.php

示例3: __construct

 /**
  * class constructor
  *
  * @access	public
  */
 public function __construct()
 {
     // global objects
     foreach (array_keys(get_object_vars(registry::instance())) as $object) {
         if (!isset($this->{$object})) {
             $this->{$object} = registry::instance()->{$object};
         }
     }
     // load database library
     $this->db = $this->load->database();
 }
開發者ID:hymns,項目名稱:phphyppo,代碼行數:16,代碼來源:AppModel.php

示例4: getInstance

 public static function getInstance()
 {
     //there is no instance
     if (!self::$instance instanceof self) {
         //si el instance es una instancia de si mismo
         self::$instance = new self();
         return self::$instance;
     } else {
         return self::$instance;
     }
 }
開發者ID:carlos195,項目名稱:template,代碼行數:11,代碼來源:registry.php

示例5: model

 /**
  * model
  *
  * load a model object
  *
  * @access	public
  * @param	string $model_name the name of the model class
  * @param	string $alias_name the property name alias
  * @param	string $filename the filename
  * @return	boolean
  */
 public function model($model_name, $alias_name = null, $filename = null)
 {
     // if no alias,  use the model name
     if (!isset($alias_name)) {
         $alias_name = $model_name;
     }
     // final check for model alias
     if (empty($alias_name)) {
         throw new Exception('Model name cannot be empty', 205);
     }
     // check valid alias name
     if (!preg_match('!^[a-zA-Z][a-zA-Z_]+$!', $alias_name)) {
         throw new Exception('Model name "' . $alias_name . '" is an invalid format', 206);
     }
     // check reserved alias name
     if (method_exists($this, $alias_name)) {
         throw new Exception('Model name "' . $alias_name . '" is an invalid (reserved) name', 207);
     }
     // model already loaded? skip
     if (isset($this->{$alias_name})) {
         return true;
     }
     // if no filename, use the lower-case model name
     if (!isset($filename)) {
         $filename = strtolower($model_name);
     }
     // assign application model path
     $filepath = APPDIR . 'models' . DS . $filename . '.php';
     // check application model path
     if (!file_exists($filepath)) {
         throw new Exception($model_name, 208);
     }
     // no problem, load application model class
     require_once $filepath;
     // class name must be the same as the model name
     if (!class_exists($model_name)) {
         throw new Exception($model_name, 209);
     }
     // get instance of registry object
     $registry = registry::instance();
     // instantiate the object as a property
     $registry->{$alias_name} = new $model_name();
     return true;
 }
開發者ID:hymns,項目名稱:phphyppo,代碼行數:55,代碼來源:AppLoader.php

示例6:

/**
 * get_instance
 *
 * set & get the registry object instance function
 *
 * @access public
 */
function &get_instance($new_instance = null)
{
    return registry::instance($new_instance);
}
開發者ID:hymns,項目名稱:phphyppo,代碼行數:11,代碼來源:AppRegistry.php


注:本文中的registry::instance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。