tidyNode::getParent
(PHP 5 >= 5.2.2, PHP 7)
tidyNode :: getParent - 返回当前节点的父节点
描述
tidyNode tidyNode::getParent ( void )
返回当前节点的父节点。
例子
Example #1 tidyNode::hasChildren() 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"
返回值
如果节点有父节点,则返回tidyNode NULL
。
← tidyNode
tidyNode::hasChildren →
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com