including files

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
tommy1987
Forum Commoner
Posts: 92
Joined: Tue Feb 21, 2006 8:35 pm

including files

Post by tommy1987 »

I have tried to include some pages, which are severel directories below the current. However I dont know how to do this, I thought of using the full http:// URL but it didnt work.

This problem is simple and I just need someone to show me how to do it.

Thanks very much..
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

When using functions that take a file path as an argument, a leading forward slash ("/") tells the function that you are referring to an absolute path as opposed to a relative one. When you pass a path without that forward slash, the function will try to look for a directory relative to the directory from which you are calling include(). An absolute path refers to a resource with respect to the root of the directory structure. You can find the root path to your account's root directory directory by calling $_SERVER['DOCUMENT_ROOT']. Start with that root path, and work your way to the file you are looking for (and don't forget the leading forward slash).
Post Reply