gpt4 book ai didi

php获取文件的根目录

转载 作者:行者123 更新时间:2023-12-04 21:28:55 29 4
gpt4 key购买 nike

如何获取主文件夹的根目录?例如我在这个位置运行文件:

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');

最佳答案

您可以使用 $_SERVER['DOCUMENT_ROOT'] 中的文档根目录。

您可以将此行包含在您的 index.php 文件中。

          include("{$_SERVER['DOCUMENT_ROOT']}includes/user/etc/function.php");

关于php获取文件的根目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10162277/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com