Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using PHP in a HTML page [closed]

Tags:

html

css

How would you add a set of html stored in a different file to the current file you are adding it to.

Here is what I mean

<body>
<HTML you have stored in /Php/slider_bar.php>
<rest of page>
</body>
like image 826
Keegan O'Reilly Avatar asked Jun 24 '26 14:06

Keegan O'Reilly


1 Answers

You can use PHP for this here's an example, but you would have to change the .html to .php

Two files, index.php and mainMenu.php the others files orders and contact are only there for demonstration.

(mainMenu.php)

<div id="mainMenu">
  <a href="index.php">Home</a>
  <a href="orders.php">Orders</a>
  <a href="contact.php">Contact</a>

Next the index.php

<html>
   <body>
      <?php
          require_once 'mainMenu.php'
      ?>
   </body>
</html>

So now the index.php page call this all the time, but simply doing

   <?php   
      require_once 'mainMenu.php'
    ?>

It will call the main menu page and display the menu in each page you put it in

like image 69
CJB Avatar answered Jun 27 '26 15:06

CJB