mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-21 19:16:23 +00:00
650 B
650 B
date | id | title |
---|---|---|
2020-11-11 | 1c3522c3-9c66-4e10-bf2d-e01807707af2 | PHP Non-capturing Catches |
Description
Since PHP 8.0, exceptions are allowed without capturing them into variables1.
Syntax
Pre PHP8
try {
changeImportantData();
} catch (PermissionException $ex) {
echo "You don't have permission to do this";
}
Post PHP8
try {
changeImportantData();
} catch (PermissionException) { // The intention is clear: exception details are irrelevant
echo "You don't have permission to do this";
}