<?php 
try {
  $pdo = new PDO('mysql:host=localhost;dbname=데이터베이스이름','root','db비번');
  $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);  //오류 내용 호출
  $output = 'DB 접속 성공';
} catch (PDOException $e) {
  $output = 'DB 접속 불가'.'<br>'.$e;
  $e->getMessage().', 위치: '. 
  $e->getFile() . ':' . $e->getLine();
}

?>
<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <?php echo $output; ?>
</body>
</html>