Bad Practice requiring file within a model?

Posted by Lee Marshall on Stack Overflow See other posts from Stack Overflow or by Lee Marshall
Published on 2012-10-11T09:32:54Z Indexed on 2012/10/11 9:37 UTC
Read the original article Hit count: 455

Filed under:
|
|

I have built an MVC php application and was wondering, if instead of having to write out a large amount of html and set the data, could I not just have all this html (with some php) in a separate file and just require it?

For example:

$test = '<div>
         Test content
         <div>More content</div>
         </div>';
$APP->Template->setData('test', $test, FALSE);

Instead could I not just use:

$test = require("includes/content.php");
$APP->Template->setData('test', $test, FALSE);

Would this be considered as bad practise? It just seems that by requiring files, it can shorten the length of controllers.

Would be good to get anybodies advice on this matter.

© Stack Overflow or respective owner

Related posts about php

Related posts about html