class_implements in PHP

Syntax of class_implements in PHP

array class_implements(mixed class[, bool autoload_class])

If class is an object, returns an array containing the names of the interfaces implemented by class’s object class. If class is a string, returns an array containing the names of the interfaces implemented by the class named class. Returns false if class is neither an object nor a string, or if class is a string but no object class of that name exists. If autoload_class is set and is true, the class is loaded through the class’s __autoload() function before getting the interfaces it implements.

Example of class_implements

<?php

interface foo { }
class bar implements foo {}

print_r(class_implements(new bar));

// you may also specify the parameter as a string
print_r(class_implements('bar'));

spl_autoload_register();

// use autoloading to load the 'not_loaded' class
print_r(class_implements('not_loaded', true));

?>

Leave a Comment