我有以下相关代码:
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());
}
Run Code Online (Sandbox Code Playgroud)
当执行此代码所在的静态函数时,我收到以下错误:
致命错误:在第107行的P:ath/to/script.php中找不到"SELF"类
我不知道是什么原因造成这种情况,有人可以赐教吗?
提前致谢.