Create a template / master page in php language [closed]

2

How can I create the structure of a master / template in PHP with alternatives other than include and require independently of content and design , thanks in advance.

for example a menu that can be visible in all the files and right there you can send data by post:

<ul>
<li>
<a>lista</a>
</li>
</ul>
    
asked by matteo 03.10.2016 в 23:17
source

1 answer

8

PHP It does not have masterPage (Without using frameworks) however there are two functions to simulate this

include () and require ()

You create two files (or more) one with name header.php and another footer.php

header.php

 <!DOCTYPE html>
<html >
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>System</title>
  <!-- Styles -->
</head>
<body>
<header>

</header>
<nav>
  <ul>
    <li><a href="#" >Home</a></li>
  </ul>
</nav>

footer.php

<footer>
   <p> footer</p>
</footer>

and on your page you want to include them would be

<?php 
  include 'header.php';/* Incluye el header ya creado */
   /* Contenido */
   <div id="main">

   </div>
  include 'footer.php'; /* Incluye el footer ya creado */

 ?>
    
answered by 03.10.2016 / 23:30
source