这是我的项目结构:
Web 根目录/文档根目录:
/var/www/ all the website files in the the 'www' folder
我想使用
require
或 include
我的文件夹中的一个文件在网络根目录/文档根目录之外:/var/extra-files
如何在
extra-files
中获取文件使用 require
的文件夹或 include
?require "OUTSIDE DOCUMENT ROOT/extra-files
谢谢
最佳答案
首先确保apache
作为读取 /var/extra-files
上文件的权限,那么您可以使用:
require "/var/extra-files/file.php";
您可能想阅读 Difference between require, include and require_once?
关于PHP获取文档根目录之外的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43713980/