2 replies [Last post]
roscoe
roscoe's picture
Offline
Enthusiast
Last seen: 13 years 44 weeks ago
Joined: 2006-03-09
Posts: 138
Points: 0

What I mean by that is that I have a header that is included in most of my pages and in the header include it includes a navigation include. I want to avoid typing in things like this:

include ('../../includes/header.php');

and I also want to be careful because of the included navigation in the header. If the header file changes paths to ../../../../includes/header.php then the navigation include wont work.

Whats the best way to fix this problem?

Tags:
roscoe
roscoe's picture
Offline
Enthusiast
Last seen: 13 years 44 weeks ago
Joined: 2006-03-09
Posts: 138
Points: 0

"If the header file changes

"If the header file changes paths to ../../../../includes/header.php then the navigation include wont work."

I meant then the images in the navigation wont work.

Tyssen
Tyssen's picture
Offline
Moderator
Brisbane
Last seen: 7 years 32 weeks ago
Brisbane
Timezone: GMT+10
Joined: 2004-05-01
Posts: 8201
Points: 1386

<?php $doc_root =

<?php $doc_root = $_SERVER['DOCUMENT_ROOT']; include("$doc_root/includes/example_include.php"); include("$doc_root/includes/example_include2.php"); ?>

How to get help
Post a link. If you can't post a link, jsFiddle it.
My blog | My older articles | CSS Reference