📅  最后修改于: 2022-03-11 14:57:06.995000             🧑  作者: Mango
$hostName = "localhost";
$dbName = "test";
$userName = "test";
$password = "test1";
try {
$pdo = new PDO("mysql:host=$hostName;dbname=$dbName",$userName,$password);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully";
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}