What is the best practice for handling multiple SQL queries in PHP, specifically in terms of establishing and closing database connections?

When handling multiple SQL queries in PHP, it is best practice to establish a single database connection and reuse it for all queries to improve performance and efficiency. This can be achieved by opening the connection at the beginning of the script and closing it at the end to release resources properly.

// Establishing a database connection
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Perform SQL queries using the same $conn object

// Closing the database connection
$conn->close();