嘿,我最近已移到PDO和OOP,並有連接聲明的問題。我收到的錯誤是;兩個PDO連接錯誤
注意:未定義的變量:DB_HOST在C:\用戶\ PC \文件\ XAMPP \ htdocs中\庫\ class.Manage.php上線14
致命錯誤:在C不能訪問空屬性:\用戶\ PC \文件\上閱讀至少任何教程PDO線14
class ManageHits{
protected $link;
protected $db_host = "localhost";
protected $db_name = "ajaxrating";
protected $db_user = "userone";
protected $db_pass = "passwordone";
function __construct(){
try{
$this->link = new PDO($this->$db_host,$this->$db_name,$this->$db_user,$this->$db_pass);
return $this->link;
}
catch(PDOException $e){
return $e->getMessage;
}
}
http://www.php.net/manual/en/language.oop5.visibility.php –