在每个页面上包括菜单 [英] Include menu on every page
问题描述
< div>
元素包括一个名为菜单或某些东西的PHP文件,只需编辑该PHP文件(所以我只需要编辑该文件而不是每个网页)?如果这是原始的PHP(没有框架),那么你只需要包含它。
include('sidebar.php');
确保您可以从包含它的地方访问该文件。如果您有一个文件夹名为 foo
,并通过 example.com/foo/somefile.php
您将不得不将include语句更改为 include('../ sidebar.php');
假设 sidebar.php
在根中。
Let's say I have a simple CSS layout and my menu is a column on the side. This menu is going to be on every web page (About 10 web pages). If I have items on this menu in the form of links and such, how can I make it so that if I add a link on one page, it will add it to all pages? Would you just make it a PHP page and in that <div>
element include a PHP file called menu or something, and just edit that PHP file (so I only have to edit that file and not every web page)?
If this is raw PHP (no frameworks) then you simply include it.
include('sidebar.php');
Make sure that you can access the file from where you are including it though. If you have files in a folder called foo
for example, and accessed via example.com/foo/somefile.php
you will have to change the include statement to include('../sidebar.php');
assuming sidebar.php
is in the root.
这篇关于在每个页面上包括菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!