Yaf_Registry::get
(Yaf >=1.0.0)
Yaf_Registry::get — 从注册表中检索条目
参数
name
注册表条目的名称。
返回值
以 name 存储的值;如果不存在该名称的条目,则返回 null。
示例
示例 #1 Yaf_Registry::get() 示例
<?php
class IndexController extends Yaf_Controller_Abstract
{
public function indexAction()
{
$redis = Yaf_Registry::get("redis");
if ($redis === null) {
throw new Exception("the redis connection is not registered");
}
$this->getView()->assign("visits", $redis->get("site:visits"));
return true;
}
}
?>参见
- Yaf_Registry::set() - 向注册表添加条目
- Yaf_Registry::has() - 检测条目是否存在
- Yaf_Registry::del() - 从注册表中移除条目
来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。
