非常希望有人能帮忙解决这个问题。我是PHP的新手。我尝试通过教程自学,但一直没有找到合适的。
基本上,我想要实现一个“如果是index.php页面,则显示foo
,如果不是,则显示bar
”。
有什么想法吗?
我希望我解释得足够清楚......
index.php包含一个侧边栏:
require_once('./cache/templates/sidebar.php');
每个后续页面都是使用此index.php文件中定义的内容构建的,这意味着sidebar.php是必须的。
我想编辑sidebar.php,包含一个仅在首页显示的广告。
目前,当我编辑sidebar.php时,例如,显示字母"B",它会在主页上显示,并在每个其他页面上显示如下;
主页:http://img.photobucket.com/albums/v684/nilsatis/1stack.jpg 其他每个页面:http://img.photobucket.com/albums/v684/nilsatis/2stack.jpg 如何指定包含文件的一个区域只在一个页面上显示,但不显示在其他页面上?
任何帮助都将非常感激。
[编辑] 这是相关网站: www.grandoldteam.com。您可以看到我在侧边栏.php中输入了“测试”文本。我希望这段文本(未来广告)仅出现在主页上,其他地方不要有。
[编辑2] 这是在index.php文件中调用sidebar.php的位置;
<p class="page_desc">'.$PAGE['subtitle'].'</p>
' );
}
if (isset($url[1])) require_once('./cache/html/'.$url[0].'/'.$url[1].'.php');
else require_once('./cache/html/'.$url[0].'.php');
}
}
require_once('./cache/templates/sidebar.php');
}
require_once('./cache/templates/footer.php');
这是我可以编辑sidebar.php以显示所需文本的位置;
<div class="clear"></div>
test
</div>
<p>
</div>