gpt4 book ai didi

即使在设置了 include_path 之后,PHP 也包含并且不需要在 ubuntu 中工作

转载 作者:行者123 更新时间:2023-12-04 19:20:00 24 4
gpt4 key购买 nike

下面是我的包含路径,如 phpinfo() 所示

include_path    .:/usr/share/php:/usr/share/pear:/var/www/html/WebPHP
/var/www/html/WebPHP/frags中有一个页面我想包含在我的 index.php 中的目录。

但没有任何效果。

我做错了什么?

编辑
    <?php
set_include_path("/var/www/html/WebPHP/frags");
ini_set('include_path', '/var/www/html/WebPHP/frags')
include 'frags/GuestHeader.php';
echo phpinfo();
?>

最佳答案

如果您只想包含一个特定文件,则应在 index.php 文件中添加:

require_once '/path/to/your/file.php'; 

但是,如果你真的想包含整个目录,你可以这样做:
set_include_path(get_include_path() . PATH_SEPARATOR . '/path/to/your/directory');

编辑:如果它仍然不起作用,您可以执行以下操作:
foreach (glob("/your/directory/*.php") as $filename) {
require_once $filename;
}

关于即使在设置了 include_path 之后,PHP 也包含并且不需要在 ubuntu 中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23561494/

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