Reputation: 28586
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'; ?>
Upvotes: 0
Views: 1692
Reputation: 8017
You can do something like this:
include($_SERVER["DOCUMENT_ROOT"] . "/header.php");
Upvotes: 2
Reputation: 28893
Try
<?php require_once('./header.php'); ?>
And adjust the path as needed, i.e. ../header
.
Upvotes: 0