Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.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
即使在设置了include_路径之后,PHP也不需要在ubuntu中工作_Php_Ubuntu_Include_Include Path - Fatal编程技术网

即使在设置了include_路径之后,PHP也不需要在ubuntu中工作

即使在设置了include_路径之后,PHP也不需要在ubuntu中工作,php,ubuntu,include,include-path,Php,Ubuntu,Include,Include Path,下面是我的include路径,如phpinfo() 在/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 'fr

下面是我的include路径,如
phpinfo()

/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;
}

由于该目录中有一些内容需要包含,因此我在这里使用了
set\u include\u path
方法,但运气不好。请尝试ini\u set('include\u path','/var/www/html/WebPHP/frags/')而不是set\u include\u path('/var/www/html/WebPHP/frags')。这有区别吗?试过了,仍然不起作用。你能编辑并发布你用于包含路径的代码吗?另外,请尝试将返回值保存在变量中,返回值显示了什么?是否检查了此目录中的权限?@Sal00m:是的,我也更改了目录和包含的php文件的权限(通过将当前用户添加为所有者)。
foreach (glob("/your/directory/*.php") as $filename) {
    require_once $filename;
}