__construct

构造函数。

Controller类是对象池模式的,它具有对象回收的机制。

所以在构造函数中初始化的所有对象,如果不是可以复用的请在destory函数中清理,同样声明的类对象也需要在destory函数中进行清理,以免影响回收后的复用。

/**
     * 销毁
     */
    public function destroy()
    {
        parent::destroy();
        unset($this->fd);
        unset($this->uid);
        unset($this->client_data);
        unset($this->request);
        unset($this->response);
        $this->http_input->reset();
        $this->http_output->reset();
        ControllerFactory::getInstance()->revertController($this);
    }

注意

在1.7.5版本后__construct方法底层修改为了final,不再允许继承修改,用户需要将代码移到initialization处。

results matching ""

    No results matching ""