View Full Version : Server Root
loomer
07-10-2003, 06:44 PM
I've done a little reading but I'm not quite sure if I've found what I wanted...
I'm trying to setup my directory structure for my site and more specifically where keep my connection info file. When i'm using an Include (connect.php) is there a way to have the path automatically start from the ROOT of my server and then I can work my way up?
That way I can more easily make changes with my paths without having to change multiple files.
any path in PHP that starts with / is processed from root - eg
/site/public_html/
people often make the mistake of adding a leading / for relative paths - which obviously doesn't work.
other symbol sets for affecting paths are
./ same directory
../ up one directory
../../ up two directories - etc
ReadMe.txt
07-10-2003, 07:41 PM
ah, i always wondered what ./ did, never seem to do anything b4 and now i know why, whats the point in it?
loomer
07-10-2003, 07:46 PM
I know the use of ../ and such.
I was inquring more about perhaps a function in PHP where it will start from the ROOT of my directory structure. So for example if certain files are a different number of directories 'up' from where my connect include will be I can use the same pointer file with all the files.
duniyadnd
07-10-2003, 10:56 PM
Try this
$_SERVER['DOCUMENT_ROOT']."/directory/name_of_file";
Then you don't have to worry which subdirectory you are in when you use that.
mordred
07-10-2003, 10:57 PM
Nope, you have to tell PHP exactly where your file to be included lies. If this file location doesn't change, you can use an absolute path for the directory in which the included files are contained.
loomer
07-11-2003, 01:51 PM
Originally posted by mordred
you can use an absolute path for the directory in which the included files are contained.
Nice one!.. duh.. Never thought about using that. I think I need a vacation. :)
Originally posted by ReadMe.txt
ah, i always wondered what ./ did, never seem to do anything b4 and now i know why, whats the point in it?
I *think* it overides include directives set in the php.ini - (not tested, just guessing)
some server setups specify the include path to start (everytime) at a certain folder - so ('folder/file.php') could be /root/incs/folder/file.php without knowing. Using ./ makes sure the path is relative to the top heirarchical calling document.
Other than that there would be no use for it.
ReadMe.txt
07-11-2003, 08:46 PM
i was actually talking about using it in a DOS command prompt, but an interesting point about the includes.
when i start an include path with /, instead of starting from the root, it starts from the include path instead, can anyone think of an easy way to override this without using ini_set?
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.