我只是在我的本地主机服务器上拼凑了一个网站的开始——Apache、MYSQL、MYPHPADMIN。在我尝试使用 $_GET 动态链接导航之前,一切似乎都运行良好。这是 index.php 中的代码:
<?php include('Config/setup.php') ?>
<?php
if ($_GET['page'] == ''){
$pg = 'home';
} else {
$pg =$_GET['page'];
}
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>FTS</title>
<link rel="stylesheet" type="text/css" href="css/Styles.css"/>
</head>
<body>
<div class ="header temp_Block">
<?php include('templates/header.php');?>
</div>
<div class ="main_nav temp_Block">
<?php include('templates/main_nav.php');?>
</div>
<div id ="Content">
<div class ="main_content temp_Block ">
<?php
include ('content/'.$pg.'php');
?>
</div>
</div>
<div class = "footer temp_Block">
<?php include('templates/footer.php');?>
</div>
</body>
</html>
当我检查我的链接以查看是否能够链接到我的各个页面时——主页、服务、关于我们等。它给了我这个错误:
Notice: Undefined index: page in C:\xampp\htdocs\test\index.php on line 6
Warning: include(content//content/homephp): failed to open stream:
No such file or directory in C:\xampp\htdocs\test\index.php on line 35
Warning: include(): Failed opening 'content//content/homephp' for inclusion
(include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\test\index.php on line 35
所以我运行它来看看 $_GET 发生了什么:
var_dump($_GET);
exit;
数组为空。它什么也没显示。我以前使用过这种方法,但不同之处在于我在托管站点上。我检查了我是否有权限问题,但我检查了 apache.conf 并没有出现任何问题。