PHP和Smarty无法正常工作
我有这个代码,我无法工作。我错过了什么?我想在除index.php之外的所有页面上显示最后一个divPHP和Smarty无法正常工作,php,if-statement,smarty,Php,If Statement,Smarty,我有这个代码,我无法工作。我错过了什么?我想在除index.php之外的所有页面上显示最后一个div {if $smarty.server.REQUEST_URI eq "index.php"} <div id="banner_container"> <div class="center"> {else} <div id="banner_top_container"> <div class="center clearfix"> {
{if $smarty.server.REQUEST_URI eq "index.php"}
<div id="banner_container">
<div class="center">
{else}
<div id="banner_top_container">
<div class="center clearfix">
{/if}
{if$smarty.server.REQUEST_URI eq“index.php”}
{else}
{/if}
您可能需要请求的前导斜杠
{if $smarty.server.REQUEST_URI == '/index.php'}
-或-
-或-
更干净的方法是将“page”变量分配给smarty实例
$smarty->assign('page','index');
您可以在其中进行测试
{if $page == 'index'}
由于索引页面上的任何其他查询字符串参数都会导致非常明确的匹配失败,但是如果我们使用的是url sometext.tld而不是页面名称,那么在我尝试使用完整url的“”和“nothing”之间应该有什么?这不起作用。有什么建议吗?我不知道你在问什么,为什么不尝试回显$smarty.server.REQUEST\u URI以了解其内容,在某些情况下甚至可能没有REQUEST\u URI。我的建议是,在PHP代码中,您应该调用var_dump($_SERVER)来了解可用于帮助您的环境第一个div在/和index.php上显示正确,但在所有其他页面上也显示正确,我想在这里显示请注意,因为{if'index.php}的计算结果将为true。。。{如果$smarty.server.REQUEST_URI='/'| |$smarty.server.REQUEST_URI=='/index.php'}
$smarty->assign('page','index');
{if $page == 'index'}