Reputation: 61
i've been trying to get a work around for this: in a file structure like this:
root:
-----index.php (file inside root)
-----template (folder inside root)
-----user (folder inside root)
-----products (folder inside root)
-----config (folder inside root)
i've been trying to use dirname(dirname(__FILE__))
inside a file in the config folder to define webroot constant but it is not working well, if i try to access the files from other folders, it's calling webroot from the current folder instead of going back to the root.
pls can any1 help me with the code/logic for defining web root in a situation like this. thanks.
Upvotes: 0
Views: 1966
Reputation: 15241
$_SERVER['DOCUMENT_ROOT'] - define some constant with what's here and away you go.
Upvotes: 0
Reputation: 10649
You can use "define":
define('ROOT', '/home/username/public_html/');
Then, in any page that the page this is defined in is included:
echo ROOT;
Upvotes: 2