What are the advantages of using PSR formatting standards in PHP code, particularly when working with PDO?

Using PSR formatting standards in PHP code helps to improve code readability, maintainability, and collaboration among developers. When working with PDO, adhering to PSR standards ensures consistency in coding style, making it easier to understand and maintain database-related code.

<?php

// Example of using PSR formatting standards with PDO
$dsn = 'mysql:host=localhost;dbname=testdb';
$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();
}