Search code examples
javascriptphpheaderincludefooter

How to add header scripts in a php web page?


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>

Solution

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

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