How do I set an absolute include path in PHP?

后端 未结 10 1899
别那么骄傲
别那么骄傲 2020-12-04 11:32

In HTML, I can find a file starting from the web server\'s root folder by beginning the filepath with "/". Like:

/images/some_image         


        
10条回答
  •  再見小時候
    2020-12-04 11:49

    One strategy

    I don't know if this is the best way, but it has worked for me.

    $root = $_SERVER['DOCUMENT_ROOT'];
    include($root."/path/to/file.php");
    

提交回复
热议问题