Is it possible to determine whether an object is of a specific class, rather than whether an object is a parent class or that class? i.e. only return true if its that specific class, and false if it is the parent class.
For example:
class ExampleClass {
...
}
class ExampleClassExtension extends ExampleClass {
...
}
$a = new ExampleClass();
$b = new ExampleClassExtension();
var_dump($b instanceof ExampleClass) //Returns true as ExampleClassExtension is inherited from ExampleClass although I would like it to return false.
Is there any way to ignore the inheritance and check whether an object is specifically that class and return false if it is the parent class or child class or just any class that isn't the specific class I'm checking for?
ifto determine multiple type you would need to start with the child classif ($foo instanceof ExampleClassExtension) { ... }elseif($foo instanceof ExampleClass) { ... }or useget_classget_class($b) === ExampleClass::class)with the code in the question.ifstatements to be the correct solution.