pQuery\DomNode::hasParent PHP Метод

hasParent() публичный Метод

Find out if node has (a certain) parent
public hasParent ( DomNode | string $tag = null, boolean $recursive = false ) : boolean
$tag DomNode | string Match against parent, string to match tag, object to fully match node, null to return if node has parent
$recursive boolean
Результат boolean
    function hasParent($tag = null, $recursive = false)
    {
        if ($this->parent !== null) {
            if ($tag === null) {
                return true;
            } elseif (is_string($tag)) {
                return $this->parent->tag === $tag || $recursive && $this->parent->hasParent($tag);
            } elseif (is_object($tag)) {
                return $this->parent === $tag || $recursive && $this->parent->hasParent($tag);
            }
        }
        return false;
    }
DomNode