How does PHP allow for the handling of Exceptions in different parts of the call stack compared to Errors?

PHP allows for the handling of Exceptions in different parts of the call stack compared to Errors by using try-catch blocks. Exceptions can be thrown in one part of the code and caught and handled in a different part of the code, allowing for more flexibility in error handling. Errors, on the other hand, are not caught by try-catch blocks and can only be handled globally.

try {
    // code that may throw an Exception
    throw new Exception('Something went wrong');
} catch (Exception $e) {
    // handle the Exception
    echo 'Caught exception: ' . $e->getMessage();
}