php include headache

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
jimthunderbird
Forum Contributor
Posts: 147
Joined: Tue Jul 04, 2006 3:59 am
Location: San Francisco, CA

php include headache

Post by jimthunderbird »

Hi All,
Recently I use php to develop a site with many subfolders. I mostly do the backend and two designers do the frontend using dreamweaver.
The site directory kind of like
/
/include/tpl.header.php
/images/header.gif
/student/class/2006.php
/student/info.php
/index.php

In the tpl.header.php file, i have code like <img src= "../images/header.gif"></img>
Then here's the catch:

In the info.php file, if I wrote: include_once("../include/tpl.header.php"); I can see the image when i open it in the browser.
But, in the index.php, if I wrote include_once("./include/tpl.header.php"); Then I can't see the image...

Also, in the 2006.php file, when I wrote include_once("../../include/tpl.header.php"); I can't see the image also...

How do I provide a good fix for this problem, since the site is growing bigger and bigger, so in the student/class/ folder, it will have more and more files later, but I wish to display the header.gif in every one of those files.


What should I do? What's the best solution?

With my best,
Jim
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

<img src="/images/header.gif" />
Post Reply