tidyNode::hasChildren

(PHP 5 >= 5.0.1)

tidyNode::hasChildren Indique si le noeud a des enfants

Description

bool tidyNode::hasChildren ( void )

Indique si le noeud courant a des enfants.

Valeurs de retour

Retourne TRUE si le noeud a des enfants, FALSE sinon.

Exemples

Exemple #1 Exemple avec tidyNode::hasChildren()

  1. <?php
  2.  
  3. $html = <<< HTML
  4. <html><head>
  5. <?php echo '<title>title</title>'; ?>
  6. <#
  7. /* code JSTE */
  8. alert('Hello World');
  9. #>
  10. </head>
  11. <body>
  12.  
  13. <?php
  14. // code PHP
  15. echo 'hello world!';
  16. ?>
  17.  
  18. <%
  19. /* code ASP */
  20. response.write("Hello World!")
  21. %>
  22.  
  23. <!-- Comments -->
  24. Hello World
  25. </body></html>
  26. Outside HTML
  27. HTML;
  28.  
  29.  
  30. $tidy = tidy_parse_string($html);
  31. $num = 0;
  32.  
  33. // La balise head
  34. var_dump($tidy->html()->child[0]->hasChildren());
  35.  
  36. // Le PHP dans la balise head
  37. var_dump($tidy->html()->child[0]->child[0]->hasChildren());
  38.  
  39. ?>

L'exemple ci-dessus va afficher :

bool(true)
bool(false)

Notes

Note:

Cette fonction était appelée tidy_node::has_children() dans PHP 4/Tidy 1.

LoadingChargement en cours