Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP获取文档根以外的文件_Php_Apache_Ubuntu_Directory_Document Root - Fatal编程技术网

PHP获取文档根以外的文件

PHP获取文档根以外的文件,php,apache,ubuntu,directory,document-root,Php,Apache,Ubuntu,Directory,Document Root,以下是我的项目结构: Web根目录/文档根目录: /var/www/ all the website files in the the 'www' folder /var/extra-files 我想使用require或在我的文件夹中的web根目录/文档根目录之外包含一个文件: /var/www/ all the website files in the the 'www' folder /var/extra-files 如何使用require或include在extra files文件

以下是我的项目结构:

Web根目录/文档根目录:

/var/www/ all the website files in the the 'www' folder
/var/extra-files
我想使用
require
在我的文件夹中的web根目录/文档根目录之外包含一个文件:

/var/www/ all the website files in the the 'www' folder
/var/extra-files
如何使用
require
include
extra files
文件夹中获取文件

require "OUTSIDE DOCUMENT ROOT/extra-files

谢谢

首先确保
apache
具有读取
/var/extra files
上文件的权限,然后您可以使用:

require "/var/extra-files/file.php";


你可能想读

嗯,哇。。。这不可能那么容易。我刚才用了这个:

/var/extra-files/myfile.php

它成功了。

使用该文件的完整路径,如
require\u once'/var/extra files/somefile.php.