开发者

write php codes independent from template

开发者 https://www.devze.com 2022-12-23 00:20 出处:网络
How can I write php codes independent 开发者_如何学Cfrom XHTML codes?You can study MVC structure.

How can I write php codes independent 开发者_如何学Cfrom XHTML codes?


You can study MVC structure.

Also have a look at smarty.


Use a PHP framework like cakePHP or Zend.
or create a custom solution and use template engine like Smarty for separating your code logic with design.


Or you can separate logic from markup only with pure php, which is in fact a good templating language.

Before doing MVC, an approach was to put code on separate classes, getting results needed on top of page and only using variables to echo or loop them inside html markup. You can use the same pattern to included portions of xhtml, the separations of concerns is then moved to pure code files and classes design.

But as we are 2010 I definitely vote for using MVC, even for very small project, with or without a framework.

0

精彩评论

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