我最近查看了CodeIgniter的代碼,看看它是如何工作的。爲什麼CodeIgniter將輸出存儲在變量中?
我不明白的一件事是爲什麼CodeIgniter將視圖生成的所有輸出存儲在一個變量中,並在腳本的末尾輸出它?
下面是在線路870
CI Source code @ GitHub
/*
* Flush the buffer... or buff the flusher?
*
* In order to permit views to be nested within
* other views, we need to flush the content back out whenever
* we are beyond the first level of output buffering so that
* it can be seen and included properly by the first included
* template and any subsequent ones. Oy!
*/
if (ob_get_level() > $this->_ci_ob_level + 1)
{
ob_end_flush();
}
else
{
$_ci_CI->output->append_output(ob_get_contents());
@ob_end_clean();
}
功能append_output追加給定字符串在CI_Output類的變量的一塊的從./system/core/Loader.php代碼。
是否有這樣做的特殊原因,而不是使用回聲陳述或只是個人喜好?
這樣的問題不會更適合[CodeIgniter的論壇](http://codeigniter.com/forums/)嗎? – Quantastical