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 ?

Member Avatar
diafol
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).

commented: Nice reply, solved my problem +1