PHP获取文件根目录之外的文件

问题描述 投票:2回答:2

这是我的项目结构:

Web根/文档根目录:

/var/www/ all the website files in the the 'www' folder

我想在我的文件夹中使用requireinclude文件在Web根目录/文档根目录下:

/var/extra-files

如何使用extra-filesrequireinclude文件夹中获取文件?

require "OUTSIDE DOCUMENT ROOT/extra-files

谢谢

php apache ubuntu directory document-root
2个回答
3
投票

首先确保apache作为读取/var/extra-files文件的权限,然后你可以使用:

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

你可能想读Difference between require, include and require_once?


0
投票

嗯哇......没办法那么容易。我刚用过这个:

/var/extra-files/myfile.php

它起作用了。

© www.soinside.com 2019 - 2024. All rights reserved.