PHP模板的页眉和页脚? [英] PHP templating for header and footer?

查看:157
本文介绍了PHP模板的页眉和页脚?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个包含关于信息,项目,事件等的多个页面的网站.

I'm making a website with multiple pages with About info, Projects, Events etc.

我的第一个问题是,如何将导航栏,页眉和页脚包含在所有html文件中,而不为每个文件复制完整的代码? 我的第二个问题是,html结构应该如何在单独的页眉/页脚文件中显示,以便可以将其包含在页面的html文件中?

My first question is, how can I include my nav bar, header and footer to be in all of the html files without copying the full code for each of them? My second question is, how should the html structure look in the separate header/footer files so I can include them in my pages html's?

如果您将PHP作为解决方案,请指向该过程的一些链接/教程.

If you mention PHP as a solution, please point me to some link/tutorial for the process.

推荐答案

如果您使用php文件,则可以执行以下操作:

If you use php files you could do something like this:

index.php:

index.php:

<? 
    include("header.php");
?>

    //page content

<?
    include("footer.php")
?>

header.php:

header.php:

<head>
    //head
</head>
<body>

footer.php:

footer.php:

<footer>
    //footer
</footer>
</body>

在header.php中,您可以放置​​标签等. 在每个页面中,您只需要包含以下文件即可

In the header.php you could put the tags etc. In every page you could just include these files than

这篇关于PHP模板的页眉和页脚?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆