What are the recommended error handling practices when attempting to establish a connection to an Oracle database in PHP using oci8?

When attempting to establish a connection to an Oracle database in PHP using oci8, it is important to implement proper error handling practices to catch any potential connection errors. This can include checking for errors returned by the oci_connect function and displaying appropriate error messages to aid in troubleshooting.

// Establishing a connection to Oracle database using oci8
$conn = oci_connect('username', 'password', 'localhost/orcl');

// Check for connection errors
if (!$conn) {
    $error = oci_error();
    echo "Connection failed: " . $error['message'];
    exit();
}