Zend_Registry 是否存活到下一个用户请求为止?
Zend_Registry 会一直存在到下一个用户请求吗?
我将此代码放在 zend 项目中的 index.php 文件的末尾:(现有 zend 网站内的代码)
试用代码:
//end of index.php file
Bootstrap::run();
//trial for find out the life of Zend_Registry.
$registry = Zend_Registry::getInstance();
if (!isset($registry['index1'])) {
Zend_Registry::set('index1', 'value7');
echo '<h1>Zend_Registry was unset</h1>';
} else {
echo '<h1>Zend_Registry was set</h1>';
}
结果每次点击主页后:
Zend_Registry 已取消设置
谢谢
Does Zend_Registry live until next user request?
I put this code in the end of index.php file in zend project:(The code inside existing zend website)
Trial code:
//end of index.php file
Bootstrap::run();
//trial for find out the life of Zend_Registry.
$registry = Zend_Registry::getInstance();
if (!isset($registry['index1'])) {
Zend_Registry::set('index1', 'value7');
echo '<h1>Zend_Registry was unset</h1>';
} else {
echo '<h1>Zend_Registry was set</h1>';
}
Results after each click to home page:
Zend_Registry was unset
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,Zend_Registry 仅针对当前请求。如果您希望数据在请求之间保留,则需要将其存储在会话中。
No, Zend_Registry is just for the current request. If you want data to persist between requests you'd need to store it in the session.