PHP 有哪些模板引擎选项?
我想知道 PHP 中有哪些模板选项? 如果模板代码可以与 PHP 非常相似,那就最好了。
I wonder what options there are for templating in PHP? If the templating code can be very similar to PHP, it'd be best.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我可以推荐 Smarty
该模板是一个纯 HTML,带有一些用于 PHP 调用的额外标记。 该模板将自身编译为 PHP 并在服务器上运行。
I can recommend Smarty
The template is a plain HTML with some extra markup for PHP calls. The template compiles itself to a PHP and runs on the server.
php 有一个 “替代”语法,使其在 html 标签中更具吸引力,我强烈推荐它。
短标签虽然大多不被鼓励和/或嘲笑,但也有一个很好的优势:
可以成为:
你可以做这样的事情:
这是你将用 php 实现的最低级别的模板,但仍然非常可读,并且不需要您可以将控制器或模型逻辑与您的视图混合在一起。
there is an "alternative" syntax to php that makes it more attractive amidst html tags, I can highly recommend it.
Short tags, though mostly discouraged and/or ridiculed also have a nice advantage:
can become:
And you can do stuff like:
Which is the lowest level templating you are going to achieve with php, but is still very readable and it does not require you to mix in controller or model logic with your view.
既然 PHP 是一个模板引擎,那么总是...... PHP。
有些人觉得有必要添加更多内容。 Smarty 非常受欢迎。 就我个人而言,我从来没有看到过这一点,但对每个人来说都是如此。
Well since PHP is a templating engine there's always... PHP.
Some feel the need to add more. Smarty is very popular. Personally I've never seen the point but to each his own.