开发者

is heredoc a good way to implement mvc?

Is Heredoc in MVC a good way to begin my foray into separating layers? I read one place it could be use and another 开发者_高级运维that heredoc had more problems than it solved.


No. HEREDOC is completely unrelated to MVC. HEREDOC is just one way to delimit strings. It's the same as asking whether Single or Double quotes are good way to separate layers.

MVC's idea is to split the user interface into three separate roles. I have answered this a few minutes before in your other MVC question, so I just link you to it. There is also a number of good other questions on SO about MVC. Just use the Search function.


Heredoc is a method of sorts, but, no it is not a good way. Especially if you are doing this inside of the controller. You should separate your "view" logic into different files then you would just include the view you need depending on the controller / action.

Doing it as an include you can easily use <?php echo $variable; ?> and do your view logic in that file. You might also consider using a prebuilt framework, such as Zend or Codeigniter, among others which take the MVC approach.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜