interface_exists
interface_exists
Checks if the interface has been defined
bool **interface_exists** string $interface bool $autoload
Checks if the given interface has been defined.
interfaceThe interface name
autoload
Whether to
if not already loaded.
autoload
Returns true if the interface given by
has been defined, false otherwise.
interface
Voorbeeld: example
<?php
// Check the interface exists before trying to use it
if (interface_exists('MyInterface')) {
class MyClass implements MyInterface
{
// Methods
}
}
?>
get_declared_interfaces``class_implements``class_exists``enum_exists