我有一个名为Notes.php的类文件。它确实有一个namespace
,当我require_once
时它会给我一个警告必需的文件,因为网址是正确的,所以也找不到。下面是类文件
目录树是:
Class
Notes
Notes.php
Database
Db.php
以下是班级代码
#Declare Namespace for the Notes class
namespace Dashboard\Api\Notes;
require_once '../Database/Db.php';
use Dashboard\Api\Database\Db;
class Notes {
# Set Protected Properties
protected $_db;
public $username;
function __construct () {
$this->_db = Db::getInstance();
}
public function getNotes() {
$query = "SELECT * FROM notes";
$result = $this->_db->query($query);
}
}
答案 0 :(得分:2)