hi guys, 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 tryoing 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.

Hi,

Why you dont use an absolute adress ? like :
URL : http://your.site/
Windows path : c:/work/sites/site01/
Linux path : /work/sites/site01/

yeah, i could, but i woludn't know d path on my host's server, & when i tried using $_SERVER['DOCUMENT_ROOT'], it's calling the constant from the users folder, instead of from the root.

Member Avatar for diafol
include($_SERVER['DOCUMENT_ROOT'] . '/template/somefile.tpl');

this should work whether you're in the root or the users folder or whether the above lies in a include file itself. You may want to define a constant for the docroot through and use that instead.

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.