What is the significance of using "instanceof" in PHP to determine the parent class of an object?

Using "instanceof" in PHP allows you to determine if an object is an instance of a specific class or a class that extends a specific parent class. This is useful for checking the type of an object before performing certain operations or accessing specific methods or properties that are defined in the parent class.

class ParentClass {
    // Parent class definition
}

class ChildClass extends ParentClass {
    // Child class definition
}

$object = new ChildClass();

if ($object instanceof ParentClass) {
    echo "Object is an instance of ParentClass or its child classes.";
} else {
    echo "Object is not an instance of ParentClass or its child classes.";
}