我在user.php
文件中添加了名称空间,这导致显示错误:
致命错误:未捕获错误:在/var/www/html/login.php:9中找不到类“用户”:堆栈跟踪:#0 {main}被抛出 /var/www/html/login.php,第9行
我尝试将"new Database\Database();"
更改为"new \PDO();"
,但这会导致另一个错误,如果有人可以帮助我,我会在Google上花费数小时后无法解决,谢谢。
user.php
<?php
namespace User;
// 'user' object
class User
{
login.php
<?php
include_once "config/core.php";
$page_title = "Login";
$require_login = false;
include_once "login_checker.php";
include_once "config/database.php";
include_once "objects/user.php";
include_once "libs/php/pw-hashing/passwordLib.php";
$database = new Database\Database();
$db = $database->getConnection();
$user = new User($db);
答案 0 :(得分:-1)
use User\User;
$user = new User($db);