PHP/Reflection/class implements

Материал из Web эксперт
Перейти к: навигация, поиск

Checking if a class implements an interface

 
interface Nameable {
    public function getName();
    public function setName($name);
}
class Book implements Nameable {
    private $name;
    public function getName() {
        return $this->name;
    }
    
    public function setName($name) {
        return $this->name = $name;
    }
}
$interfaces = class_implements("Book");
if (isset($interfaces["Nameable"])) {
}