我有
下的数据库类class Database {
private $db_link;
private $db_host;
private $db_user;
private $db_password;
private $database_name;
public function __construct($filename){
include ("include/".$filename);
$this->db_link = new mysqli($db_host,$db_user,$db_password);
if($this->db_link->connect_error){
throw new Exception("Database is not available. ".$this->db_link->connect_errno);
}
问题是if块没有执行,即使我把错误的细节连接到mysql数据库...请指出我是否正在解决它错误,因为我是OOP的新手
try{
$db = new Database($filename);
echo "connected";
}
catch(Exception $e){
echo "message: ".$e->getMessage();
exit();
}