Get Smarty


Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Buy cheap glasses from and save up to 80%.

Where to buy prescription glasses? is your best choice!

Where to buy discount wedding dresses and cheap smart dresses free shipping -

Shop for 2018 World Cup Football Boots Online sale at

Browse best 2018 world cup soccer cleats and shoes from




Smarty已经废弃{php}标签,强烈建议不要使用。 请把你的PHP逻辑放到PHP程序或者插件函数中实现。


在Smarty 3.1,{php}仅在SmartyBC中可用。

{php}标签可以允许PHP代码直接嵌到模板中使用。 这些代码是否被编码,需要取决于$php_handling 的设置.

Example 7.61. {php}标签的使用

   // including a php script directly from the template.


Example 7.62. {php}标签中使用全局变量来赋值变量

{* this template includes a {php} block that assign's the variable $varX *}
   global $foo, $bar;
   if($foo == $bar){
     echo 'This will be sent to browser';
  // assign a variable to Smarty
{* output the variable *}
<strong>{$varX}</strong> is my fav ice cream :-)


参见 $php_handling, {include_php}, {include}, {insert}组件化模板.

No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Email: (not shown)
What is 14 plus 13? (Are you human?)