PDA

View Full Version : Include in root directory


Switch17
07-03-2003, 03:28 PM
Is there any way that I direct an include statement to the root path of my site? I've currently got this:
include("link_path.php");, which works as long as the file is in the same subdirectory.

But I'd like to place the file in my root directory, so I don't have to have the file in multiple subdirectories. I had hoped that either
include("http://www.mysite.com/link_path.php"); or
include("../link_path.php"); would work, but unfortunately, it didn't work for me.

Also, I had search and found this post Here (http://www.codingforums.com/showthread.php?s=&threadid=10244&highlight=include+root+path), but I'm little confused on understanding it all.

Is something that can be easily done?

Nightfire
07-03-2003, 04:24 PM
I read somewhere that if you're using the latest (stable) version of php, not php5, you'll use includes like. But I have no idea if that's your case, or if that's just the way the host set up that persons server.

include("/var/www/html/include_dir/include.php");

SpeedFreak
07-03-2003, 06:00 PM
$_server['DOCUMENT_ROOT']; will get the document root so you could use something like:

include $_server['DOCUMENT_ROOT'] . "/file.php";


but its much easier just to find the full server path to your directory and use that. eg:

include('/home/user/public_html/file.php');


you can get that info from your webhost or just simply make a blank php file called xxxx.php with only the following:

<?
include('blah.php');
?>

as long as blah.php doesnt exist it will return an error which will say "warning: failed to create stream, no such file or directory in /path/to/file/xxxx.php on line 2"
with /path/to/file being the full server path to your dir

Cheers