【问题标题】:Kohana 3 - ConstructorKohana 3 - 构造函数
【发布时间】:2010-05-29 18:57:21
【问题描述】:

我尝试使用public function __construct() { },但出现错误

ErrorException [严格]:创建 来自空值的默认对象。

这背后的原因是我使用了一个仅对登录用户进行保护的控制器,我不想在控制器中的每个操作中都调用$this->protect();

因此我尝试使用调用$this->protect();的构造函数

【问题讨论】:

    标签: php authentication constructor kohana-3


    【解决方案1】:

    before() 方法中使用您的登录保护...

    public function before() {
        parent::before();
        $this->protect();
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-02
      • 1970-01-01
      • 2021-03-07
      • 1970-01-01
      • 2010-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多