Include a menu on every page

Say I have a simple CSS layout, and my menu is a column on the side. This menu will be placed on each web page (about 10 web pages). If I have elements in this menu in the form of links, etc., How can I make it so that if I add a link to one page, it will add it to all pages? Would you just make it a PHP page and in that element <div>include a PHP file called a menu or something else and just edit that PHP file (so I only need to edit this file, not every web page)?

+3
source share
4 answers

If this is raw PHP (without frameworks), you just turn it on.

include('sidebar.php');

, , . foo, , example.com/foo/somefile.php, include include('../sidebar.php');, , sidebar.php .

+6

, .

, , :

<?php include("/yourMenu.php"); ?>

yourMenu.php , .

+2

, . include php

+1

Source: https://habr.com/ru/post/1758481/


All Articles