array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'tidynode.getparent.php', 1 => 'tidyNode::getParent', 2 => 'Returns the parent node of the current node', ), 'up' => array ( 0 => 'class.tidynode.php', 1 => 'tidyNode', ), 'prev' => array ( 0 => 'tidynode.getnextsibling.php', 1 => 'tidyNode::getNextSibling', ), 'next' => array ( 0 => 'tidynode.getprevioussibling.php', 1 => 'tidyNode::getPreviousSibling', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/tidy/tidynode/getparent.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>
(PHP 5 >= 5.2.2, PHP 7, PHP 8)
tidyNode::getParent — Returns the parent node of the current node
此函数没有参数。
示例 #1 tidyNode::getParent() example
<?php
$html = <<< HTML
<html><head>
<?php echo '<title>title</title>'; ?>
<#
/* JSTE code */
alert('Hello World');
#>
</head>
<body>
Hello World
</body>
</html>
HTML;
$tidy = tidy_parse_string($html);
$num = 0;
$node = $tidy->html()->child[0]->child[0];
var_dump($node->getParent()->name);
?>
以上示例会输出:
string(4) "head"