How can using an object-oriented approach in PHP, like using mysqli as an object, improve database connection handling compared to a procedural approach?

When using an object-oriented approach in PHP, like using mysqli as an object, it allows for better organization and encapsulation of code related to database connections. This approach helps in improving database connection handling by providing a more structured way to interact with the database, reducing the chances of errors and making the code more maintainable.

// Object-oriented approach using mysqli
$mysqli = new mysqli("localhost", "username", "password", "database");

if ($mysqli->connect_error) {
    die("Connection failed: " . $mysqli->connect_error);
}

// Perform database operations using $mysqli object