tidyNode::hasChildren
(PHP 5 >= 5.0.1, PHP 7)
tidyNode :: hasChildren - 检查节点是否有子节点
描述
bool tidyNode::hasChildren ( void )
告诉节点是否有孩子。
返回值
返回TRUE
节点是否有子节点,FALSE
否则返回。
例子
Example #1 tidyNode::hasChildren() example
<?php
$html?=?<<<?HTML
<html><head>
<?php?echo?'<title>title</title>';??>
<#?
??/*?JSTE?code?*/
??alert('Hello?World');?
#>
</head>
<body>
<?php
??//?PHP?code
??echo?'hello?world!';
?>
<%
??/*?ASP?code?*/
??response.write("Hello?World!")
%>
<!--?Comments?-->
Hello?World
</body></html>
Outside?HTML
HTML;
$tidy?=?tidy_parse_string($html);
$num?=?0;
//?the?head?tag
var_dump($tidy->html()->child[0]->hasChildren());
//?the?php?inside?the?head?tag
var_dump($tidy->html()->child[0]->child[0]->hasChildren());
?>
上面的例子将输出:
bool(true)
bool(false)
← tidyNode::getParent
tidyNode::hasSiblings →
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com