我有一个index_test.php,代码如下:
<!-- Center colon -->
<div id="centerCol">
<?php
$page = $_GET['page']; // To get the page
if($page == null) {
$page = 'index_test'; // Set page to index_test, if not set
}
switch ($page) {
case 'index_test':
include('frontPage.php');
break;
case 'about':
include('about.php');
break;
case 'contact':
include('contact.php');
break;
}
?>
和左侧菜单的另一个div:
<?php
unset($_GET);
echo "<a href='index_test.php/?page=index'>Front Page</a>"; // set page to index
echo "<a href='index_test.php/?page=about'>About</a>"; // page = about
echo "<a href='index_test.php/?page=contact'>Contact</a>"; // page = contact
?>
[它基于这个stackoverflow答案,是的,非常简单,但无论如何我需要了解更多:PHP file layout/design]
我不明白的是当我点击我得到的链接时:
index_test.php /?页=索引
然后我点击菜单项,我得到例如:
index_test.php / index_test.php /?页=约
然后
index_test.php / index_test.php / index_test.php /?页=接触
等等它被卡住了所以如何清除它并修复这个和哪里(index_test.php或leftMenu.php在菜单div中调用)
答案 0 :(得分:1)
使用base_url系统,
$base_url = "http://your_file_path";
如果您使用localhost&#34; http://localhost/your_file_path&#34;
<?php
unset($_GET);
echo "<a href='" .$base_url. "index_test.php/?page=index'>Front Page</a>"; // set page to index
echo "<a href='" .$base_url. "index_test.php/?page=about'>About</a>"; // page = about
echo "<a href='" .$base_url. "index_test.php/?page=contact'>Contact</a>"; // page = contact
?>