downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

tidyNode::isHtml> <tidyNode::isAsp
[edit] Last updated: Fri, 17 May 2013

view this page in

tidyNode::isComment

(PHP 5 >= 5.0.1)

tidyNode::isCommentIndique si le noeud représente un commentaire

Description

bool tidyNode::isComment ( void )

Indique si le document est un commentaire.

Valeurs de retour

Retourne TRUE si le document est un commentaire, FALSE sinon.

Exemples

Exemple #1 Extrait les commentais depuis un document HTML

<?php

$html 
= <<< HTML
<html><head>
<?php echo '<title>title</title>'; ?>
<# 
  /* code JSTE */
  alert('Hello World'); 
#>
</head>
<body>

<?php
  // code PHP 
  echo 'hello world!';
?>

<%
  /* code ASP  */
  response.write("Hello World!")
%>

<!-- Comments -->
Hello World
</body></html>
Outside HTML
HTML;


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

get_nodes($tidy->html());

function 
get_nodes($node) {

    
// Vérifie si le noeud courant est du type demandé
    
if($node->{"isComment()) {
        echo "
\n\n# Noeud commentaire #" . ++$GLOBALS['num'] . "\n";
        
echo $node->value;
    }

    
// Vérifie si le noeud courant a des enfants
    
if($node->hasChildren()) {
        foreach(
$node->child as $child) {
            
get_nodes($child);
        }
    }
}

?>

L'exemple ci-dessus va afficher :

# Noeud jste #1
<# 
  /* code JSTE */
  alert('Hello World'); 
#>

Notes

Note:

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



add a note add a note User Contributed Notes tidyNode::isComment - [0 notes]
There are no user contributed notes for this page.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites