mysqli的异常处理功能?
class check{
private $host;
private $name;
private $paw;
public $res;
function connect($host,$name,$paw){
// var_dump($host,$name,$paw);exit();
$this->res = @new mysqli($host,$name,$paw);
//
if(!$this->res){
throw new Exception("MySQL connect is error!");
}
}
}
try {
$a = new check();
$a->connect("localhost","root","123jodjg");
}catch (Exception $e){
echo $e->getMessage();
}
这个是代码。如果不用mysqli来做。用mysql_connect这样的函数来做就没问题的