我正在用PHP Smarty编写if语句,并且语法有问题。
$post['user_name'] = Chris
我想要这样,如果在这种情况下,$post['post_type'] == "hiddenshared"
的URL URI等于"/$profile['user_name']"
,则什么也不显示。我很难将/chris
与/
变量连接在一起。如何以使$profile['user_name']
显示其中包含的字符串而不显示文本/
的方式在$profile['user_name']
变量之前添加$profile['user_name']
?还是我不应该使用$profile['user_name']
?
这是我的代码
REQUEST_URI
如果应该将if语句读取为{if $post['post_type'] == "hiddenshared" && ($smarty.server.REQUEST_URI === "/$profile['user_name']")}
{else}
<!-- post -->
{$smarty.server.REQUEST_URI}
{$profile['user_name']}
{/if}
,则if语句将/$profile['user_name']
读取为/$profile['user_name']
。我该如何解决?
答案 0 :(得分:1)
您可以在双引号中使用大括号定界符
$smarty.server.REQUEST_URI === "/{$profile['user_name']}"