如何重用html作为页脚

I see multiple answers about creating php files in order to reuse headers/footers, but nothing specific enough. I can't seem to get it to work.

What exactly would the php file look like and what exactly would my html file look like (given the code as it currently is, below)? do I have to convert all my html files to php files in order to use the php include line?

<div id="footer2-wrap">  
    <div class="container">  
        <table id="header">  
            <tr>  
                <td class="phone-number"><span class='wsite-text wsite-phone'>Copyright 2015 | xxx Corporation</span></td>
            </tr>

                    </table>
    </div>

You should work with include(), require() or require_once functions in PHP to include your files, which depends on your situation.

For instance, let's assume you have a basic php file, called index.php and you want to add sidebar.php, footer.php, navigation.php.

index.php

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="utf-8">
    <link rel="stylesheet" href="style.css"/>
</head>
<body>
    <?php 
    include("sidebar.php");
    include("navigation.php");
    include("footer.php"); // we include footer.php here. you can use .html extension, too.
    ?>
</body>
</html>

footer.php (or html)

<a href="">About us</a>
<a href="">Our work</a>
<a href="">Testimonials</a>
<a href="">What we do</a>
<a href="">Contact us</a>

Create a new file with your footer data. Let's give it the name: footer.php:

<div id="footer2-wrap">  
    <div class="container">copyright etc...</div>
<div>

Then inside your master template (or index.php file), include the footer file:

include_once('footer.php');

Yes, you must have a .php file to use PHP, your server must also have PHP installed (but most already do). PHP also adds to the loading time of a page, so take that into consideration when using it. To add the footer with PHP, you can use the PHP function include(), or, I am not sure if this is considered correct, with file-get-contents():

include():

<?php 
    include("footer.html");
?>

file-get-contents():

<?php
$footer = file_get_contents('footer.html');
echo $footer;
?>

You could also do the same thing with JavaScript:

var xmlhttp, text;
xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET', 'http://www.example.com/file.txt', false);
xmlhttp.send();
text = xmlhttp.responseText;
document.getElementById("footer").innerHTML=text;

Code taken from here.

Note: The file must be on the same domain to use JS.

First create a file called menu.php(if you use .html it wont work) On that php file write the html code for your menu

<div id="navbar">
more code
</div>


At your main html file write 
<?php 
    include("menu.php");
?>

The code should be able to run. Make sure you are running the code via Apache. Download Xammp or wammp. Start Apache, copy paste your project folder to the xammp folder under httdocs. Then on your browser type in localhost/[your project name] and make sure the html files are changed to .php.