Here is how you can handle easily multiple error exceptions thanks to PHP 7.1!
๐ Source code of the example project gist.github.com/pH-7/5ba7f83a9e1befc46a6837..
Example ๐
try {
$person = new Person('Pierre');
echo $person->greeting('morning'); // can be 'morning', 'afternoon', or 'evening'
} catch(InvalidNameException | InvalidDayMomentException $err) { // Catch multiple exceptions at once
echo $err->getMessage();
}
๐ My Udemy course on how to build a real-world PHP 8 application from scratch is now available: udemy.com/course/create-real-world-php-weba..
๐ My GitHub github.com/pH-7 where I regularly publish packages, libraries, and proof of concepts.
ย