-1

I have several pages that use the same scripts, for this, i want create a header.php and footer.php file and call them on each page, example.

header.php

<link rel="stylesheet" href="../Framework/bootstrap/css/bootstrap.min.css"/>
<link rel="stylesheet" href="../Framework/bootstrap/css/bootstraptheme.min.css" />

footer.php

<script src="../Framework/jquery/jquery.min.js"></script>
<script src="../Framework/bootstrap/js/bootstrap.min.js"></script>

and my php web page:

 <html>
 <head>
    //add header.php
 </head>
 <body>


  //add footer.php
  </body>
  </html>
chris85
  • 23,846
  • 7
  • 34
  • 51
Alonso Contreras
  • 605
  • 2
  • 12
  • 29
  • Use `include` or `require` depending on how you want the page to function if the resource in unavailable. – chris85 Jun 24 '17 at 20:15
  • Possible duplicate of [Creating a PHP header/footer](https://stackoverflow.com/questions/8054638/creating-a-php-header-footer) – Andrew Myers Jun 24 '17 at 20:18

3 Answers3

0
<html>
 <head>
    <?php require('header.php'); ?>
 </head>
 <body>


  <?php require('footer.php'); ?>
  </body>
  </html>

As chris85 pointed - you can use include instead of require...

Yedidia
  • 969
  • 7
  • 12
0
<html>
 <head>
    <?php include('header.php');?>
 </head>
 <body>
   <?php include('footer.php');?>
 </body>
</html>
-1

You can achieve this with jquery as

<html>
 <head>
    <script src="//code.jquery.com/jquery-1.10.2.js"></script>
    <div id="header"></div> //add header.php
 </head>
 <body>


  <div id="footer"></div> //add footer.php
  <script>
  $(document).ready(function(){
  $('#header').load('header.html');
  $("#footer").load("footer.html"); 
  });
  </script>
  </body>
  </html>
Rahul
  • 2,374
  • 2
  • 9
  • 17