
// 异常处理类
try{
// 捕获异常
$dsn = 'mysql:dbname=s72;host=localhost;charset=utf8';
$user = 'root';
$pwd = '123';
$pdo = new PDO($dsn, $user, $pwd);
}catch(Exception $e){
// 处理异常
// echo '链接数据库失败';
echo $e->getMessage().'<br>';
echo $e->getLine().'<br>';
echo $e->getFile().'<br>';
echo $e->getCode().'<br>';
}
文章来源: php 异常处理 try { }catch(Exception $e){echo $e->getMessage()}
人吐槽 | 人点赞 |
发表评论