<?php
class FooException extends Exception {}
class BarException extends Exception {}
try {
throw new FooException();
} catch (FooException | BarException $e) {
echo get_class($e) . PHP_EOL;
}
try {
throw new BarException();
} catch (FooException | BarException $e) {
echo get_class($e) . PHP_EOL;
}