How can error handling be implemented in the "sendSMS" function to address possible issues with the SMS sending process?

Issue: Error handling can be implemented in the "sendSMS" function by using try-catch blocks to catch any exceptions that may occur during the SMS sending process. This allows for graceful handling of errors and prevents the script from crashing if an issue arises.

function sendSMS($phoneNumber, $message) {
    try {
        // Code to send SMS
        $response = send_sms_to_phone_number($phoneNumber, $message);
        
        if($response['status'] == 'success') {
            echo "SMS sent successfully!";
        } else {
            throw new Exception("Failed to send SMS");
        }
    } catch (Exception $e) {
        echo "Error: " . $e->getMessage();
    }
}