syntax error, unexpected ‘)’, expecting ‘|’ or variable (T_VARIABLE)¶
Description¶
Until PHP 8.0, exceptions always had to be named, with a variable.
Here, the error message is signaling that it expected another exception to catch, separated from the first one by a |
, or a variable name.
Example¶
<?php
try {
} catch (E) {}
?>
Solutions¶
Add a variable name to the catch clause.
Add another exception to catch, and then a name to the catch clause.
Upgrade to PHP 8.0 or more recent.