$connection = mysqli_connect("localhost", "username", "password", "database"); // Some database operations mysqli_close($connection);
$pdo = new PDO("mysql:host=localhost;dbname=database", "username", "password"); // Some database operations $pdo = null;In this example, the $pdo object is set to null to close the database connection. Package library used in these examples is mysqli and PDO, respectively.