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 ?

Recommended Answers

All 2 Replies

Member Avatar
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?


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

commented: Nice reply, solved my problem +1

Its the first one, thanks a lot !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.