在所有页面中正确包含php头文件 [英] Correctly include php header in all pages

查看:137
本文介绍了在所有页面中正确包含php头文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会在网站的所有页面中包含一个php标头( mysite.com/header.php )。

I would include a php header (mysite.com/header.php) in all the pages from a site.

如何正确地做到这一点?

How to do it properly?

有相关链接:

There are relative links:

<?php include_once 'header.php'; ?>
<?php include_once '../header.php'; ?>

这并没有帮助:

And this didn't help:

<?php include_once '/header.php'; ?>


推荐答案

你可以这样做:

include($_SERVER["DOCUMENT_ROOT"] . "/header.php");

这篇关于在所有页面中正确包含php头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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