【发布时间】:2012-04-27 02:00:21
【问题描述】:
如何获取主文件夹的根目录?例如我在这个位置运行文件:
public_html/admin/user/etc/index.php
我想包含来自
的文件public_html/includes/user/etc/function.php
所以我想做这样的事情:
include(get_first_default_folder().'includes/user/etc/function.php');
代替:
include('../../../includes/user/etc/function.php');
【问题讨论】:
-
将 /path/to/public_html 添加到 include_path 或使用引导程序中的路径创建一个 PUBLIC_HTML 常量
-
也可能是 $root = 'public_html';许多应用程序需要知道根安装目录。