<?php
class A {

}
class B {

}
class Displayable {

}
$b = new B;


var_dump($b instanceof B);
var_dump($b instanceof A);
var_dump($b instanceof Displayable);

?>

    bool(true)
    bool(false)
    bool(false)

    As expected? I see nothing wrong here.

      If you are asking how to test this in code to make some logical decision, perhaps, you could :

      if($b instanceof Displayable) {
          echo "yes";
      } else {
          echo "no";
      }
      

      You can also do the same thing with the is_a() function if you prefer -- just a style choice, really.

        Write a Reply...