如何在模板中动态加载内容

I have 6 files.

  1. header.php
  2. footer.php
  3. home.php
  4. page1.php
  5. page2.php
  6. 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";

?>

How can i dynamically change the content of index.php when i click on the links?

Main structure :

index.php --> Layout + handles which page to display
header.php --> Included in index
footer.php --> Include in index

Links would be something like index.php?page=home

index.php:

<html>
    <head>
        <title></title>
    </head>
    <body>

    <?php include 'header.php'; ?>

    <?php 

       // Handle here what page to include : 
       // - Store $_GET['page']
       // - Sanitize the var
       // - Check if you have a file that would correspond to this page
       // - Include it

    ?>

    <?php include 'footer.php'; ?>

    </body>
</html>

header.php :

<header>
    ....
</header>

footer.php :

<footer>
 .....
</footer>

You will need a different script for each URL:

index.php

<?php

    include "header.php";
    //content goes here
    include "home.php";  
    //content goes here
    include "footer.php";

?>

page1.php

<?php

    include "header.php";
    //content goes here
    include "page1_content.php"; //contains contents of page1
    //content goes here
    include "footer.php";

?>

page2.php

<?php

    include "header.php";
    //content goes here
    include "page2_content.php"; //contains contents of page2
    //content goes here
    include "footer.php";

?>