2014-02-14 120 views
0

我试图使用PHP和MySQL做一个登录系统,但是这意味着出现的消息,而不是:Array([0]=>mysql[1]=> host)这是出现:致命错误和警告?

Warning: require_once(0): failed to open stream: No such file or directory in C:\xampp\htdocs\myfiles\core\init.php on line 21 

Fatal error: require_once(): Failed opening required '0' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\myfiles\core\init.php on line 21 

任何人都知道这是为什么发生,我能做些什么来停下来?

而且这是的init.php的第21行:在PHP require_once 'classes/' + $class + '.php';

+1

require_once需要一个表示文件路径的字符串,你传递它0,这不是文件路径 –

+1

你试图包含'require_once()'的文件不存在。你可能走错路了。 –

+0

使用'.'而不是'+'连接你的路径字符串。 http://www.php.net/manual/en/language.operators.string.php – showdev

回答

1

字符串连接与.操作完成。您包含的路径为:

require_once 'classes/' . $class . '.php'; 

您应该考虑在您的课程中使用AutoLoader。这个机制的标准化有PSR-0

+0

谢谢,但现在是即将到来的: 致命错误:类'配置'找不到C:\ xampp \ htdocs \ myfiles \ index.php第4行 – Fred

+0

这是index.php中的第4行:echo Config :: get('mysql/host'); //'127.0.0.1' – Fred