[英]Require_once failed to open stream: No such file or directory
I have this error:我有这个错误:
Warning: require_once(../questionTypes/Question.php): failed to open stream: No such file or directory in /home/u949913003/public_html/includes/essential.php on line 25
警告:require_once(../questionTypes/Question.php):无法打开流:第 25 行的 /home/u949913003/public_html/includes/essential.php 中没有这样的文件或目录
Fatal error: require_once(): Failed opening required '../questionTypes/Question.php' (include_path='.:/opt/php-5.6/pear') in /home/u949913003/public_html/includes/essential.php on line 25
致命错误:require_once(): Failed opening required '../questionTypes/Question.php' (include_path='.:/opt/php-5.6/pear') in /home/u949913003/public_html/includes/essential.php第 25 行
I require essential.php from New_test.php like this:我需要来自 New_test.php 的 Essential.php,如下所示:
require_once('../essential.php');
Then in essential.php, I require Question.php like this:然后在 Essential.php 中,我需要这样的 Question.php:
require_once($config['systemQuestionTypesClassDir'].'Question.php');
$config
is defined in config.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/';
My folders structure is this:我的文件夹结构是这样的:
Obviously in questionTypes there is Question.php.显然在 questionTypes 中有 Question.php。
I don't know ho to solve this.我不知道如何解决这个问题。
Calling "include" from another "include" could cause problems when they are relative paths.当它们是相对路径时,从另一个“包含”调用“包含”可能会导致问题。 If you use the absolute path, it shouldn't be a problem.
如果你使用绝对路径,应该没有问题。
You could use __DIR__
to get the directory that contains the file where this is written.您可以使用
__DIR__
获取包含写入文件的目录。
I think this should works:我认为这应该有效:
File: New_test.php
文件:
New_test.php
require_once(__DIR__ .'/../essential.php');
File: essential.php
文件:
essential.php
require_once(__DIR__ .'/../questionTypes/Question.php');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.