I want to include a .php file, containing a menu bar, in all my pages. Thing is, some of these pages are at different levels: for example, on might be in the root directory, another might be in root/news, another in root/news/2012, and so on. What can I do to make this include always link back to the menu bar file, which is located in my root directory?
Patiodude
0
Newbie Poster
Recommended Answers
Jump to PostYou could do something like
include('path/to/file/header.php'); //path/to/file being full path name
Jump to Postno you can use
include('http//yourdomain.com/header.php');
Jump to Postok you need to set the absolute path now this depends how you webserv is setup.
add this to you header.php (menu bar file)echo $_SERVER['DOCUMENT_ROOT'];
this will give the full path to header.php file then use this instead of
All 9 Replies
glycerine
0
Newbie Poster
Patiodude
0
Newbie Poster
glycerine
0
Newbie Poster
Patiodude
0
Newbie Poster
glycerine
0
Newbie Poster
Patiodude
0
Newbie Poster
glycerine
0
Newbie Poster
Patiodude
0
Newbie Poster
glycerine
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.