Hi guys,
I am searching for the definitive way of obtaining the root directory of my app. I need to it to work on localhost and also on ALL platforms, NIX, Windows etc. I would like to do this as I wish to use it to locate all my sub directory files - includes, model etc.
For example, I may have this as my landing page:
http://www.mywebsite.com/index.php
The root directory might be:
html
The index.php might reside here:
html/index.php
... but my includes files might be here:
html/lib/includes
So I would be looking to obtain the root in an absolute kind of way to allow me to string together the includes sub directory in a relative kind of way.
In summary then:
1. How to obtain the root with 100% percent success, all of the time on all platforms.
2. How to string the sub directory together with 100% percent success, all of the time on all platforms.
3. Any comments on this as an approach, also welcome.
Many thanks in advance,
S
Definitive way of obtaining the root directory.
Moderator: General Moderators
Re: Definitive way of obtaining the root directory.
1: $_SERVER['DOCUMENT_ROOT']
2 and 3: It is perfectly possible (and from a security point of view perhaps even favorable*) to put libraries, include files, etc outside the document root. So merely scanning inside the root is definitely not guaranteed to locate all files involved in your website.
(* because it makes sure those library and include files are not directly accessible from outside, amongst other reasons)
2 and 3: It is perfectly possible (and from a security point of view perhaps even favorable*) to put libraries, include files, etc outside the document root. So merely scanning inside the root is definitely not guaranteed to locate all files involved in your website.
(* because it makes sure those library and include files are not directly accessible from outside, amongst other reasons)