What potential issue arises when using die() in PHP scripts for error handling?

Using die() in PHP scripts for error handling can abruptly terminate the script, making it difficult to handle errors gracefully. To solve this issue, it's better to use exceptions for error handling in PHP. By throwing exceptions, you can catch and handle errors in a more controlled manner, allowing for better error reporting and recovery.

try {
    // Code that may throw an exception
    if ($error_condition) {
        throw new Exception('An error occurred.');
    }
} catch (Exception $e) {
    // Handle the exception
    echo 'Caught exception: ' . $e->getMessage();
}