What is the significance of deriving custom exception classes from the base Exception class in PHP?

By deriving custom exception classes from the base Exception class in PHP, we can create specific exception types that allow us to handle different types of errors more effectively. This approach helps in organizing and managing exceptions in a structured manner, making it easier to identify and handle specific types of errors in our code.

class CustomException extends Exception {
    // Custom exception code here
}

try {
    // Code that may throw exceptions
    throw new CustomException("An error occurred.");
} catch(CustomException $e) {
    echo "Custom Exception caught: " . $e->getMessage();
} catch(Exception $e) {
    echo "Generic Exception caught: " . $e->getMessage();
}