正确分离 PHP 中的逻辑/样式

2021-12-24 00:00:00 layout templates php

我只是想知道在 PHP Web 项目中将逻辑组件与布局分开的最​​佳方法是什么?

I'm just wondering what is the best way to separate logic components from the layout in a PHP web project?

内容存储在MySQL中,逻辑是PHP,模板当然是HTML/CSS.我的问题是,如何最好地解决这个问题(不使用 CMS).

The content is stored in MySQL, the logic is PHP and the templates are HTML/CSS of course. My question is, how to solve this issue best (without using a CMS).

greetz, poescholn

greetz, poeschlorn

推荐答案

使用 模板引擎,例如Smarty.

或者只使用带有嵌入式 php 的 HTML 作为模板,注意不要在模板中放入太多逻辑.

Alternatively just use HTML with embedded php for templates, just be careful not to put too much logic into the template.

相关文章