What are some potential reasons for choosing PDO over mysqli for database connections in PHP?

When choosing between PDO and mysqli for database connections in PHP, some potential reasons for selecting PDO include its support for multiple database systems, prepared statements that help prevent SQL injection attacks, and its object-oriented approach which can make code more readable and maintainable.

// Using PDO for database connection
$dsn = 'mysql:host=localhost;dbname=mydatabase';
$username = 'username';
$password = 'password';

try {
    $pdo = new PDO($dsn, $username, $password);
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
    echo 'Connection failed: ' . $e->getMessage();
}