如何对多个页面使用单个Index.php文件
我正在制作一个包含一个index.php文件的应用程序。我还有其他几页:如何对多个页面使用单个Index.php文件,php,Php,我正在制作一个包含一个index.php文件的应用程序。我还有其他几页: contact_form_homepage.php contact_form_config.php contact_form_doc.php contact_form_stats.php contact_form_premium.php 我正在寻找一种方法,我可以将所有页面链接到index.php,这样,每当用户单击Home,他就可以联系\u form\u homepage.php,每当他单击Config,他就
contact_form_homepage.php
contact_form_config.php
contact_form_doc.php
contact_form_stats.php
contact_form_premium.php
我正在寻找一种方法,我可以将所有页面链接到index.php,这样,每当用户单击Home,他就可以联系\u form\u homepage.php,每当他单击Config,他就可以联系\u form\u Config.php等等
i、 e
我应该使用哪种php魔术?请帮忙我通常的技巧是包含一个php模块。我通常把我的放在site/
action
.php中
您可以在我的框架的第105行看到这一点
// get the action
$ac=get_from_get('p');
$ua = "";
$is_mvc = 0;
// if no action specified this is the default action.
if ($ac=="")
$ac="login";
// attempt include the PHP for the action
$file = "site/$ac.php";
if (file_exists($file))
include($file);
else
{
header("HTTP/1.0 404 Not Found");
exit;
}
只需像上面所说的那样做一个链接
<a href="http://apps.facebook.com/mtkenya-dev/index.php?p=contact_form_config&tab=contact_form_config&page_id=2" title="contact_form_config" class="fbtab">Configuration</a>
您可以做一件事,这取决于查询字符串参数,如“p=contact\u form\u config”, 您可以在index.php文件中加载相应的页面 d、 当查询字符串参数为p=contact\u form\u config时,您可以使用以下代码
if($_GET['p'] == "contact_form_config ")
{
// you can load your page now
include_once('contact_form_config.php');
}
希望这会有帮助:)include($\u GET['p']);这是一个很好的开始。还要考虑如果P不在URL中,请上帝不要!还考虑如果$yGET(‘p’)=‘可能在代码中放置在哪里(如果$yGET [’pAGEYID’=2){头(“位置:CeltExtFixFixFig.gph.php”);}可能是在顶部附近。(在你的下面比较容易理解,但是让我试试所有的选项,就是liberalPlease让我看一个使用if语句的例子,只使用这个页面contact_form_config.php。之后我会尽我所能解决剩下的问题。谢谢上面的例子请注意我在上面的链接中是如何包含
page_id=2
谢谢Richard,太棒了!!让我来看看,我通过live Example Spushkar学习得很快,非常感谢,让我尝试所有这些选项,并向大家提供反馈。谢谢所有你的方法是最简单的。如果一切都正常,请你就这个问题投票。我现在寻求的那部分有效。不过我仍然需要你的帮助,我能让你继续吗社交媒体??请与我共享您的社交媒体。我将很快添加您:)
if($_GET['page_id'] == 2) {
header("Location: contact_form_config.php");
}
if($_GET['p'] == "contact_form_config ")
{
// you can load your page now
include_once('contact_form_config.php');
}