...

View Full Version : Need abit help with 'Includes' or some alternatives.



cryonic
03-15-2008, 05:38 PM
If this has been asked before, please delete or move it.

Let's say I made dir001 (within doc root) and place a file 001.php. Now inside dir001, i make a new dir, dir002 with a file 002.php inside it. Now inside file 002.php, is it possible to 'include' file 001.php which is outside its dir? If 'include' doesn't work, has anyone got any suggestions which i can play use or play around?

InsaneRhino
03-15-2008, 06:17 PM
include ('../dir001/001.php');

Should work. But I'm not 100% sure. If not you can use full directories such as:


include ('http://www.yoursite.com/dir001/001.php');

Inigoesdr
03-15-2008, 07:03 PM
If not you can use full directories such as:


include ('http://www.yoursite.com/dir001/001.php');

Using the URL will only work if the server has allow_url_fopen is on. You should use the full file path if the relative one doesn't work. ie. /home/username/public_html/dir001/001.php This path will vary depending on the server, but you can find it in the phpinfo().

_Aerospace_Eng_
03-15-2008, 08:09 PM
Or most of the time this works as well...

include($_SERVER['DOCUMENT_ROOT'].'/dir001/001.php');

cryonic
03-19-2008, 04:58 PM
Thanks, it works.

aedrin
03-19-2008, 07:12 PM
include ('../dir001/001.php');

Should work. But I'm not 100% sure.

This technique will work, and is the recommended way. Although if dir002 is contained within dir001, the path should be: ../001.php



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum