【发布时间】:2014-02-06 12:13:33
【问题描述】:
我有 6 个文件。
- header.php
- footer.php
- home.php
- page1.php
- page2.php
- index.php
header.php
<html>
<head>
<title>test</title>
</head>
<body>
<div class="menu">
<ul>
<li><a href="home.php>Home</a></li>
<li><a href="page1.php>Page 1</a></li>
<li><a href="page2.php>Page 2</a></li>
</ul>
</div>
<div class="content">
footer.php
</div>
</body>
</html>
index.php
<?php
include "header.php";
//content goes here
include "home.php"; //this include must change when i click on page 1 or page 2 link
//content goes here
include "footer.php";
?>
如何在点击链接时动态更改 index.php 的内容?
【问题讨论】:
-
你为什么不创建页面并提供链接?
-
你想用
include "page1.php";替换include "home.php";是你想要的吗?如果是这样,为什么不创建链接? -
好吧,我只想要 index.php 来处理所有事情。我只想创建将由 index.php 加载的页面
-
检查 Smarty smarty.net 模板引擎。也许它会帮助你。您可以将变量添加到 tmp 文件中并稍后对其进行修改,您还可以调用并包含不同的文件等。您可以对您的系统执行类似的操作,但我建议您尝试 Smarty。它为此目的而构建。