【问题标题】:Showing error in ZF 2ZF 2 显示错误
【发布时间】:2014-03-01 21:44:01
【问题描述】:

我在 ZF2 中使用 ZfcUser (https://github.com/ZF-Commons/ZfcUser) 模块。我使用 facebook 登录。登录后出现以下错误。

致命错误:在第 2 行对 D:\php\htdocs\zend_test\module\Dom\view\dom\dom\index.phtml 中的非对象调用成员函数 getEmail()

代码存在于第2行

<?php echo $this->gravatar($this->zfcUserIdentity()->getEmail()) ?> 

谁能说出问题出在哪里?

谢谢

【问题讨论】:

  • 显然 zfcUserIdentity() 不包含用户对象。这就是根本原因,为什么不是这样,这是你要弄清楚的;)

标签: php zend-framework2 zfcuser


【解决方案1】:

您应该始终检查用户是否已登录。否则

$this->zfcUserIdentity()

返回空值。这是为了避免错误。 检查用户是否登录类型

<?php if(!$this->zfcUserIdentity()) {
    echo $this->gravatar($this->zfcUserIdentity()->getEmail());
} ?>

您没有登录的原因可能是在 facebook 登录实现中。

Source

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-12-13
    • 1970-01-01
    • 2011-05-30
    • 2017-12-25
    • 1970-01-01
    • 2015-03-23
    • 2011-03-09
    • 1970-01-01
    相关资源
    最近更新 更多