SERVER_NAME
is not the way it should be the actual domain name. You can enable REQUEST_URI
, which will give you an absolute path from the point of view of the web server (provided that you just use the files. REQUEST_URI provides you with the path entered by the user. The web server or PHP itself can deliver content that is not even in the file)
For this, it really depends on what in $some_relative_path
DOCUMENT_ROOT is the absolute path to the server where the files on your website really live on the server. DOCUMENT_ROOT may be useful for including other PHP files, but it should never be exposed to the connecting client, as this is a security risk.
They should never be the same in any scenario unless for some reason someone installs /
on the server as the root of the document. This is likely to be a very bad idea, because then even system files will be available on the Internet.
source share