Catch Without Variable

A catch clause doesn’t require a storing variable anymore. It may simply omit it. The exception is then caught, but not provided in the clause.

PHP code

<?php

try {
    throw new Exception('Error');
} catch (Exception) {
    print 'Exception caught';
}

?>

Before

Parse error: syntax error, unexpected ')', expecting '|' or variable (T_VARIABLE)

After

Exception caught

PHP version change

This behavior changed in 8.0