How can one effectively manage and close SQL database connections in PHP?

To effectively manage and close SQL database connections in PHP, it is important to always close the connection after executing the queries to free up resources and prevent potential issues with reaching the maximum number of connections allowed by the database server. This can be done by using the `mysqli_close()` function to explicitly close the connection when it is no longer needed.

// Establish connection
$connection = mysqli_connect("localhost", "username", "password", "database");

// Check connection
if (!$connection) {
    die("Connection failed: " . mysqli_connect_error());
}

// Perform queries

// Close connection
mysqli_close($connection);