在Smarty模板中集成PHP代码

在Smarty模板中集成PHP代码,php,smarty,template-engine,Php,Smarty,Template Engine,我使用Smarty来实现我的模板。我怎样才能写出这个PHP句子 模板引擎的发明是为了将业务逻辑(以及请求本身)与表示逻辑分离开来。模板引擎不应处理$\u GET、$\u POST、$\u会话等 如果您需要根据$_GET['action']做出决定,那么只需使用reguler smarty的分配从控制器传递即可 无论如何,如果您不希望代码更具逻辑性和明显性,可以使用$smarty.get.action {if empty($smarty.get.action)}class="current"{/i

我使用Smarty来实现我的模板。我怎样才能写出这个PHP句子


模板引擎的发明是为了将业务逻辑(以及请求本身)与表示逻辑分离开来。模板引擎不应处理$\u GET、$\u POST、$\u会话等

如果您需要根据$_GET['action']做出决定,那么只需使用reguler smarty的
分配从控制器传递即可

无论如何,如果您不希望代码更具逻辑性和明显性,可以使用
$smarty.get.action

{if empty($smarty.get.action)}class="current"{/if}
像这样:

{if !isset($smarty.get.action)}class="current"{/if}

非常感谢。我想使用
如果($\u GET['action']=='open'){}
有手册或文档?是的。这里有一些应该很有用的文档:哇,太简单了。我刚刚发现正确的代码
{if($smarty.get.action=='details')}class=“current”{/if}
:)非常完美!不过,如果要在键入时保存两个字符,则不需要括号:Dthanks!我想给
$\u GET['action']='detail'
赋值,我写道:
{if($smarty.GET.action='detail')class=“current”{/if}
,但我得到了一个error@Mini:
{if($smarty.get.action eq'detail')class=“current”{/if}
@zerkms:谢谢我使用
{if($smarty.get.action='details')}class=“current”{/if}
什么是最好的==或eq?thanks@Mini:它们是同义词。我曾经使用
eq
@zerkms谢谢:)在那里我可以找到所有函数和参数。