smarty禁止php,Smarty的模板中不允许PHP的代码?

/******************************************************************************

* Smarty的模板中不允许PHP的代码?

* 说明:

* 在将PHP的代码转换为Smarty的模板的过程中,遇到Smarty无法转换PHP代码的问题,

* 原因是这个功能被禁止了,因为既然使用Smarty模板,那么PHP代码做的事情尽量放在

* Controller那里,这样可读性会更高。

*

* 2017-3-13 深圳 南山平山村 曾剑锋

*****************************************************************************/一、参考文档:1. Using PHP code inSmarty tpl FIle

http://stackoverflow.com/questions/7446851/using-php-code-in-smarty-tpl-file

2. Using PHP inside Smarty template files [duplicate]

http://stackoverflow.com/questions/14877736/using-php-inside-smarty-template-files

3. How to add PHP code to .tpl file [duplicate]

http://stackoverflow.com/questions/9601547/how-to-add-php-code-to-tpl-file

4. Using PHP code inSmarty tpl FIle

http://stackoverflow.com/questions/7446851/using-php-code-in-smarty-tpl-file

5. Difference between Smarty and SmartyBC classes

http://stackoverflow.com/questions/35863410/difference-between-smarty-and-smartybc-classes

二、原因:1. SmartyBC is a Backwards Compatibility Wrapper. it allows {php} and {include_php} inside templates. Both tags were dropped with the Smarty 3.1release.2. You shouldn‘t add PHP code to the template. It will make whole idea of templates spoiled. You have to add PHP code to controller, not template.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值