What are some potential consequences of closing a database connection prematurely in a PHP script?

Closing a database connection prematurely in a PHP script can lead to resource leaks and potential performance issues. It is important to always close the connection after you have finished executing your queries to release the resources properly.

// Open a connection to the database
$connection = new mysqli($host, $username, $password, $database);

// Execute your queries here

// Close the connection
$connection->close();