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

PHP Native Interfaces

PHP defines its own native interfaces. They are used with the native classes, and are usually available with custom code.

For example, Countable is a PHP native interface, which designates objects that can be passed to the count() function. On the other hand, Throwable is a native interface, which is characteristic of Exception and Error. It may be used for typing, with catch clauses, or with instanceof but must be implemented by extending the two former classes.

Native interfaces depend on the compiled extensions. Native interfaces are introduced in major or minor versions, so their number evolves with time.

<?php

    print_r(get_declared_interfaces());

?>

Documentation

See Also