PHP require file from top directory

后端 未结 6 652
梦毁少年i
梦毁少年i 2020-12-05 07:11

I have several subdomains contained in their own directory above my root site, and an assets folder in my root directory. For example:

/
/assets/
/forums/
/b         


        
6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-05 08:13

    You have 2 solutions. You can either use the full URL to the file, for instance if your file is in the 'lib' directory you can use: require_once ('http://www.example.com/lib/myfile.php')

    or

    You can try the $_SERVER['DOCUMENT_ROOT'] function in PHP but this isnt always fool proof.

提交回复
热议问题