Document Root PHP

后端 未结 4 963
时光说笑
时光说笑 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:19

    Just / refers to the root of your website from the public html folder. DOCUMENT_ROOT refers to the local path to the folder on the server that contains your website.

    For example, I have EasyPHP setup on a machine...

    $_SERVER["DOCUMENT_ROOT"] gives me file:///C:/Program%20Files%20(x86)/EasyPHP-5.3.9/www but any file I link to with just / will be relative to my www folder.

    If you want to give the absolute path to a file on your server (from the server's root) you can use DOCUMENT_ROOT. if you want to give the absolute path to a file from your website's root, use just /.

提交回复
热议问题