Forum Moderators: coopster
i am trying to establish a path structure which didnt work using $document_root so i have to use the domain instead. (this is for includes and css files btw)
1. [mydomain.com...] (works)
2. /images/image.jpg (works)
3. $DOCUMENT_ROOT/images/image.jpg (doesn't)
am i right in assuming $DOCUMENT_ROOT is like using the number 1 method or have i misunderstood it?
please help.
TIA
you need to use $_SERVER['DOCUMENT_ROOT']
it functions the same as your first example BUT it doesn't work the same :) the document root is basically the web root local path of your user directory on the server.
when you log into ftp or cpanel file manager you start off in "/home/user/" which is above the web root directory. The contents of your site or home page [example.com...] is usually found or starts in "/home/user/public_html/" or something similar which is the web root.
$_SERVER['DOCUMENT_ROOT'] refers to this directory(/home/user/public_html)
that's how I understand it, if I'm wrong with a certain aspect then someone correct please.
www.mydomain.com/home/username/public_html/images/image.jpg would then be /home/username/public_html/home/username/public_html/images/image.jpg
while
www.mydomain.com/images/image.jpg would be the same as /home/username/public_html/images/image.jpg
so I just think of $_SERVER['DOCUMENT_ROOT'] as / or www.mydomain.com/