我有以下相关代码:致命错误:类“自我”找不到
try {
self::$db = new PDO($dsn, self::USER, SELF::PASS); //Connect to the database, and store the pdo object.
self::$db->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
}
catch (PDOException $e) {
throw new Exception("There have been an error in the connection: ". $e->getMessage());
}
当执行静态函数的代码是,我得到以下错误:
Fatal error: Class 'SELF' not found in P:ath/to/script.php on line 107
我不知道什么可能会导致这种情况,任何人都可以请赐教?
在此先感谢。
你知道的事情,当你在5小时的一个项目工作,直看不到有什么不对你的脚本,即使这很明显吗?谢谢你的回答,你先回答,我会接受你的回答,但你们都会得到upvotes:D –
@Truth哦,我知道它太好:) –
@Truth,这就是为什么好的编辑可能会帮助很多;) –