Zend_Registry 是否存活到下一个用户请求为止?

发布于 2024-09-26 19:46:10 字数 620 浏览 0 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

智商已欠费 2024-10-03 19:46:10

不,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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文