Welcome Guest, Not a member yet? Register   Sign In
Direct echo in Controller - bad parctice?
#1

I'm quite new to CodeIgniter and have been putting together a very small website which is directly copied from some static PHP that I maintain. Following the tutorial (version 2) and then moving on to the general topics led me to put a few direct echo statements in my default controller in order to attempt to add some CSS, metadata and third party JavaScript to the resulting page's
Code:
<head></head>

Everything started to come out in the wrong order. Other MVC tutorials found by Google imply that it is a bad idea for a controller to produce output in this way, and sure enough when I swapped over to using
Code:
$this->output->append_output()
everything started to work a lot more neatly. Is this the right approach? If so, I think it would be helpful to update the documentation for controllers to make this clear.

Chris.
Reply


Messages In This Thread
Direct echo in Controller - bad parctice? - by ChrisRitson - 04-01-2015, 02:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB