PHP include file in webroot from file outside webroot

后端 未结 5 1344
没有蜡笔的小新
没有蜡笔的小新 2020-12-03 20:02

I have a php file outside my webroot in which I want to include a file that is inside the webroot.

folder outside webroot
- > php file in which

5条回答
  •  遥遥无期
    2020-12-03 20:17

    Full path should be:

    include('/home/xx/xx/domains/mydomain/webroot/file-to-include.php');
    

    Or you should set the path like:

    include(__DIR__ . '/../webroot/file-to-include.php');  // php version >= 5.3
    include(dirname(__FILE__) . '/../webroot/file-to-include.php');  // php version < 5.3
    

提交回复
热议问题