odeigniter php
frameworks will be learn about processing
output of controllers in the title of “Codeigniter php frameworks:
controllers part 5”. I think you must follow previous part of controllers to
know about codeigniter controllers. We have learn about controller in the part
1, 2, 3, and 4. I suggest you to read
these part before you read this part.
Now let’s go to the lesson of part 5. Processing output, codeigniter has an output class
that takes care of sending your final rendered data to the web browser automatically.
More information on this can be found in the View and Output Class in the next
lesson of Codeigniter php frameworks. In
some cases, however, you might want to post-process the finalized data in some
way and send it to the browser yourself. Codeigniter permits you to add a
function named _output() to your controller
that will receive the finalized output data.
For important information, if your controller contains a
function named _output(), it will always be
called by the output class instead of echoing the finalized data directly. The first
parameter of the function will contain the finalized output. I think you must
save that information in your memory of Codeigniter php frameworks.
Code bellow is example of processing
output:
public function _output($output)
{
echo $output;
}
And note this again, that your _output()
function will receive the data in finalized state. Benchmark and memory usage
data will be rendered, cache file written (if your caching enabled), and header
will be sent (if you use that feature) before it is handed off to the _output() function.
To have your controller’s output cached properly, its _output() method can use this code:
if ($this->output->cache_expiration > 0)
{
$this->output->_write_cache($output);
}
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 in the codeigniter user guide.
I think this enough, we will see you in the part 6 of
controllers, stay up to date on Codeigniter php frameworks.
This post of Codeigniter php frameworks: controllers part 5
is references from http://codeigniter.com/user_guide/general/controllers.html.
Comments
Post a Comment