try {
$dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass);
} catch (Exception $e) {
echo "Failed: " . $e->getMessage();
}