Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Exception Polymorphism

<?php

interface i {}

class myException extends Exception implements i {}

try {
    throw new myException();
} catch(i $i) {
    var_dump($i instanceof myException);
}

Custom exceptions are like any other classes: they may implements interfaces. Later, that interface may be used to catch the exception, even if the interface has nothing to do with exceptions. And with several interfaces on the same exception, it is possible to catch them in different ways.

See Also

PHP Features

Last updated: 10 September 2026