需要传递给另一个方法

时间:2015-12-02 13:58:03

标签: php function methods return

有人可以帮我解决这个问题。 我不知道是否有可能。

我有这段代码

    /*===================================================
    =            This block can't be changed            =
    ===================================================*/

    if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/footer.tpl')) {
        $this->template = $this->config->get('config_template') . '/template/common/footer.tpl';
    } else {
        $this->template = 'default/template/common/footer.tpl';
    }

    $this->render(); // need to have same effect of "return $this->render();"

    /*=====  End of This block can't be changed  ======*/

并编写了另一种处理render方法的方法:

protected function render()
{
    return $this->load->view($this->template, $this->data);
}

当调用方法render假定渲染方法返回相同时,我需要这样做。

" $这 - >渲染();"需要具有相同的效果"返回$ this-> render();"

任何?

1 个答案:

答案 0 :(得分:0)

尝试输出缓冲。

http://php.net/manual/en/book.outcontrol.php

http://php.net/manual/en/outcontrol.examples.basic.php

ob_start();
$this->render();
$buffer = ob_get_flush();