从另一个php文件中插入另一个php文件[关闭]

Assuming that i have 4 pages in trial folder

  1. index.php
    • contains only navigational bar which is consists of home button, about button and contact button.
  2. home.php
    • contains image slider
  3. About.php
  4. contact.php

I am using a xampp server to run these file and the url that shows when i run the code is http:// localhost/TRIAL/ which redirects to the index.php page. Is there any way for me to insert the other page(home.php,about.php,contact.php) to the index.php page when i click on the navigation buttons so that the file name of the pages that are open will not be shown? I would like to know if there are any ather way so that the link will remain to be http:// localhost/TRIAL/ instead of the http://localhost/TRIAL/about.php.

You can have the navigation buttons trigger a jQuery load() event.

<nav>
    <ul>
        <li><a href="#" id="nav-home">Home</a></li>
        <li><a href="#" id="nav-about">About</a></li>
    </ul>
</nav>
<script>
    $(document).ready(function() {

        $('#nav-home').click(function() {
            $('#content').load('about.php');
            return false;
        });

    });
</script>
<div id="content"></div>

Hope that helps

What you are looking for is include.

<?php
//Contents of Index Page

//Include Files
include './home.php';
include './about.php';
include './contact.php';
?>

The './' is used to include the files in the same sub directory as the index.php