PHP Include

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
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

PHP Include

Post by spacebiscuit »

Hi,

I am having some trouble using php include function.

Please consider the following directory structure:

I have a php script in the following directory:

res/common/

The file I am trying call via the include function is in the following directory:

includes/

I am calling the file as follows:

Code: Select all

include("includes/menu.php")
This does not work so I have also tried:

Code: Select all

include("../../includes/menu.php")
The only way I can get it to work is as follows:

Code: Select all

include("http://www.mydomain/includes/menu.php")
It seems odd that I can only call the function successfully if I use the domain name.

Any thoughts?

Thanks,

Rob.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

try:

Code: Select all

include($_SERVER['DOCUMENT_ROOT'].'includes/menu.php');
Post Reply