Welcome Guest, Not a member yet? Register   Sign In
in the view, php embedded into html or php echo the whole html?
#5

[eluser]tonanbarbarian[/eluser]
given that CI is a MVC framework then I feel that there should be minimal PHP code in the views. This means that I would never echo the html but rather embed the php in the html

The reason for this is simple. MVC helps to promote code seperation. Controller seperate from Models seperate from Views. This means that you can have 1 (or more) developer who codes the controllers, another (or more) who codes the models and yet another (or more) who works with the views. If you have the views written as embedded php it is much easier for someone with limited PHP skills but advanced HTML/CSS etc skills to modify the views. If the html is all echoed there is too much of a chance of something going wrong and the resulting view not displaying correctly.

Even if I am building an app that I "think" I will be the only maintainer on I always plan that some day someone else may need to maintain it, so like good documentation, nicely formatted code, including html in views, is essential.


Messages In This Thread
in the view, php embedded into html or php echo the whole html? - by El Forum - 06-29-2009, 08:39 PM



Theme © iAndrew 2016 - Forum software by © MyBB