diff options
Diffstat (limited to 'user_guide/libraries/output.html')
-rw-r--r-- | user_guide/libraries/output.html | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/user_guide/libraries/output.html b/user_guide/libraries/output.html index ab8f1d683..3e18fa0d9 100644 --- a/user_guide/libraries/output.html +++ b/user_guide/libraries/output.html @@ -28,7 +28,7 @@ <div id="masthead"> <table cellpadding="0" cellspacing="0" border="0" style="width:100%"> <tr> -<td><h1>CodeIgniter User Guide Version 2.0.0</h1></td> +<td><h1>CodeIgniter User Guide Version 2.0.1</h1></td> <td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td> </tr> </table> @@ -78,6 +78,21 @@ It is possible, however, for you to manually intervene with the output if you ne For example, if you build a page in one of your controller functions, don't set the output until the end.</p> +<h2>$this->output->set_content_type();</h2> + +<p>Permits you to set the mime-type of your page so you can serve JSON data, JPEG's, XML, etc easily.</p> + +<code>$this->output<br/> + ->set_content_type('application/json')<br/> + ->set_output(json_encode(array('foo' => 'bar')));<br/> +<br/> +$this->output<br/> + ->set_content_type('jpeg') // You could also use ".jpeg" which will have the full stop removed before looking in config/mimes.php<br/> + ->set_output(file_get_contents('files/something.jpg'));</code> + +<p><strong>Important:</strong> Make sure any non-mime string you pass to this method exists in config/mimes.php or it will have no effect.</p> + + <h2>$this->output->get_output();</h2> <p>Permits you to manually retrieve any output that has been sent for storage in the output class. Usage example:</p> |