一旦无法打开流:没有这样的文件或目录

我有这个错误:

警告:require_once(../ questionTypes / Question.php):无法打开流:在25行/home/u949913003/public_html/includes/essential.php中没有这样的文件或目录

致命错误:require_once():在/home/u949913003/public_html/includes/essential.php上打开所需的'../questionTypes/Question.php'(include_path ='。:/ opt / php-5.6 / pear')失败25行

我需要从New_test.php这样的essential.php:

require_once('../essential.php');

然后在essential.php中,我需要这样的Question.php:

require_once($config['systemQuestionTypesClassDir'].'Question.php');

$config在config.php中定义:

$config['controller']['a'] = 'Admin';
$config['controller']['e'] = 'Teacher';
$config['controller']['t'] = 'Teacher';
$config['controller']['s'] = 'Student';
$config['controller']['at'] = 'Teacher';
$config['controller']['er'] = 'Teacher';
// System directories
$config['systemControllersDir'] = '../controllers/';
$config['systemQuestionTypesClassDir'] = '../questionTypes/';
$config['systemViewsDir'] = '../views/';
$config['systemLibsDir'] = 'libs/';
$config['systemLangsDir'] = 'langs/';
$config['systemQuestionTypesLibDir'] = $config['systemLibsDir'].question;
$config['systemLangsXml'] = '../resources/languages/';
$config['systemExtraDir'] = = 'extra/';
$config['systemFpdfDir'] = 'fpdf/';
$config['systemPhpGraphLibDir'] = 'phpgraphlib—master/';
$config['systemFileManagerDir'] = 'filemanager/';

我的文件夹结构是这样的:

在这里输入图像描述

questionTypes中显然有Question.php。

我不知道何去解决这个问题。


如果是相对路径,从另一个“包含”调用“include”可能会导致问题。 如果你使用绝对路径,不应该是一个问题。

您可以使用__DIR__来获取包含写入文件的目录。

我认为这应该起作用:

文件: New_test.php

require_once(__DIR__ .'/../essential.php');

文件: essential.php

require_once(__DIR__ .'/../questionTypes/Question.php');
链接地址: http://www.djcxy.com/p/69253.html

上一篇: once failed to open stream: No such file or directory

下一篇: once :failed to open stream: no such file or directory