Document Root PHP

后端 未结 4 962
时光说笑
时光说笑 2020-12-03 04:39

Just to confirm, is using:

$_SERVER[\"DOCUMENT_ROOT\"]

the same as using: /

in HTML.

Eg. If current document is:

         


        
4条回答
  •  青春惊慌失措
    2020-12-03 05:21

    Yes, on the server side $_SERVER['DOCUMENT_ROOT'] is equivalent to / on the client side.

    For example: the value of "{$_SERVER['DOCUMENT_ROOT']}/images/thumbnail.png" will be the string /var/www/html/images/thumbnail.png on a server where it's local file at that path can be reached from the client side at the url http://example.com/images/thumbnail.png

    No, in other words the value of $_SERVER['DOCUMENT_ROOT'] is not / rather it is the server's local path to what the server shows the client at example.com/

    note: $_SERVER['DOCUMENT_ROOT'] does not include a trailing /

提交回复
热议问题