CakeFest 2024: The Official CakePHP Conference

tidyNode::hasChildren

(PHP 5, PHP 7, PHP 8)

tidyNode::hasChildrenIndica si un nodo tiene hijos

Descripción

public tidyNode::hasChildren(): bool

Indica si el nodo tiene hijos.

Parámetros

Esta función no tiene parámetros.

Valores devueltos

Devuelve true si el nodo tiene hijos, false de lo contrario.

Ejemplos

Ejemplo #1 Ejemplo de tidyNode::hasChildren()

<?php

$html
= <<< HTML
<html><head>
<?php echo '<title>titulo</title>'; ?>
<#
/* código JSTE */
alert('Hola Mundo');
#>
</head>
<body>

<?php
// código PHP
echo 'Hola Mundo!';
?>

<%
/* código ASP */
response.write("Hola Mundo!")
%>

<!-- Comentarios -->
Hola Mundo
</body></html>
Fuera del HTML
HTML;


$tidy = tidy_parse_string($html);
$num = 0;

// La etiqueta HEAD
var_dump($tidy->html()->child[0]->hasChildren());

// El código PHP dentro de la etiqueta HEAD
var_dump($tidy->html()->child[0]->child[0]->hasChildren());

?>

El resultado del ejemplo sería:

bool(true)
bool(false)

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top