|
今天在看手册的时候看到关于处理输出的时候手册中给了_output()这么一个方法:
处理输出
CodeIgniter 拥有一个输出类用来确保你修改的数据会自动被传递给浏览器。关于这个的更多信息可以在视图和输出类里找到。有些时候,你可能想要自己发布修改一些最终的数据或是自己把它传递给浏览器。CodeIgniter 允许你给你的控制器增加一个名为 _output() 的方法来接收最终的数据。
注意: 如果你的控制器包含一个 _output() 方法,那么它将总是被调用,而不是直接输出最终的数据。这个方法类似于OO里的析构函数,不管你调用任何方法这个方法总是会被执行。
例如:
function _output()
{
echo 'I am here';
}
请注意,你的 _output() 将接收最终的数据。 Benchmark and memory usage data will be rendered, cache files written (if you have caching enabled), and headers will be sent (if you use that feature) before it is handed off to the _output() function. If you are using this feature the page execution timer and memory usage stats might not be perfectly accurate since they will not take into acccount any further processing you do. For an alternate way to control output before any of the final processing is done, please see the available methods in the Output Class.
不太理解这个接受最终的数据是什么意思,上网查了,有人说:“_output() 方法:类中任意函数的输出结果都会交给此函数处理后再交给客户浏览器 ”,可是还是不能理解,这个输出结果都交给此函数处理是怎么个处理法,是说任意函数的输出无法直接输出到页面,得先经过_output()处理之后才可以还是什么?可是我不知道怎么使用这个函数,想请会的大哥大姐们指点一下,谢谢了 |
|