$servername = "localhost"; $username = "db_username"; $password = "db_password"; $dbname = "database_name"; // Create a new PDO object try { $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); // Set PDO error mode to exceptions $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); echo "Connected successfully"; } catch(PDOException $e) { echo "Connection failed: " . $e->getMessage(); }In this example, we are creating a new PDO object using the mysql driver with the given server name, database name, username, and password. We are then setting the error mode to throw exceptions and testing whether the connection was successful by trying to output the message "Connected successfully". The package library for getConnection is PDO, which is a built-in PHP extension that provides a convenient way to interface with databases using an object-oriented approach.