首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

tidyNode::hasChildren

(PHP 5 >= 5.0.1, PHP 7)

tidyNode :: hasChildren - 检查节点是否有子节点

描述

代码语言:javascript
复制
bool tidyNode::hasChildren ( void )

告诉节点是否有孩子。

返回值

返回TRUE节点是否有子节点,FALSE否则返回。

例子

Example #1 tidyNode::hasChildren() example

代码语言:javascript
复制
<?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());

?>

上面的例子将输出:

代码语言:javascript
复制
bool(true)
bool(false)

← tidyNode::getParent

tidyNode::hasSiblings →

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com