php - trying to understand some functions related to zend -
/** * getter method, same offsetget(). * * method can called object of type zend_registry, or * can called statically. in latter case, uses default * static instance stored in class. * * @param string $index - value associated $index * @return mixed * @throws zend_exception if no entry registerd $index. */ public static function get($index) { $instance = self::getinstance(); if (!$instance->offsetexists($index)) { if ($instance->lazyload($index, $return)) { return $return; } else { throw new zend_exception("no entry registered key '$index'"); } } return $instance->offsetget($index); } ... public static function getdb() { return self::get('db'); } ...
this taken xenforo/application.php, although comment clear, still have questions:
$instance = self::getinstance();
line mean here?$instance->lazyload;
not find declaration of method:lazyload, zend file?$instance->offsetget($index)
, saw declaration in spl.php, is:
public function offsetget ($index) {}
, empty inside {}, how function?
here brief explanation threee question
1. $instance = self::getinstance(); line mean here?
answer 1. getinstance method used class instance without doing $test = new class_name(); getinstance method static can class instance without declaring new class_name(); in getinstance method checking _instance set? if not set create own class instance , return instance.
2. $instance->lazyload; not find declaration of method:lazyload, zend file?
answer 2. can understand lazyload below link have better idea lazyload. link
3. $instance->offsetget($index), saw declaration in spl.php, is: public function offsetget ($index) {}, empty inside {}, how function?
answer 3. method can called object of type zend_registry, or can called statically. in latter case, uses default static instance stored in class.
parameters: string $index - value associated $index returns: mixed exceptions: zend_exception if no entry registerd $index.
pls let me know if more..
Comments
Post a Comment