954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Detect install directory folder

Hello,

I need a php code that can detect the root foldername that my website is installed to. I need to use this constant in my bootstrap.php so it can't be relative to where the file is called from. Atm I have my root folder and admin folder. I need the index.php at my admin folder to be able to use the installation folder name. How can this be achieved ?

Martin C++
Light Poster
43 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
 
echo __DIR__;

will give the exact location of the system from the point of view of the actual file where it's called - not the parent file if it is an include file.

Is that it?

echo $_SERVER['DOCUMENT_ROOT'];


*should* give you the document root (path to public root).

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,800 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

Its the first one, thanks a lot !

Martin C++
Light Poster
43 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You