发生了一些奇怪的事情。
以下是来自的片段view_reminders.php
:
<?php
namespace reminder;
require_once('./reusable/reminders.php');
?>
some HTML...
<?php
$reminders = new Reminders(); # STATEMENT THAT THROWS AN ERROR : LINE 23
$reminder_details = $reminders->get_reminders();
foreach($reminder_details as $reminder) {
echo $reminder;
}
?>
在上面的脚本中,语句$reminders = new Reminders()
抛出了一个错误:Fatal error: Class 'reminder\Reminders' not found in E:\Installed_Apps\xampp\htdocs\remind\view_reminders.php on line 23
。
我不明白这个错误。以下是来自的片段reminders.php
:
<?php
namespace reminder;
namespace connection;
require_once('./reusable/connection.php');
Class Reminders{
private $user_info;
private $userID;
private $reminder_info;
private $reminder_count;
.
.
.
}
现在为什么在Reminders
找到脚本时找不到类reminders.php
?
注意:目录结构:
+--->resuable
+---->connection.php
---->reminders.php
---->view_reminders.php
view_reminders.php
就在外面connection.php
,reminders.php
在reusable
目录里面。