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这样的函数来做就没问题的
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号