<?php
$html = <<< HTML <html><head> <?php echo '<title>Titre</title>'; ?> </head> <body>
<?php echo 'Bonjour le monde !'; ?>
</body></html> HTML;
$tidy = tidy_parse_string($html); $num = 0;
get_php($tidy->html());
function get_php($node) {
// vérifie si le noeud courant est du code PHP if($node->isPHP()) { echo "\n\n# PHP node #" . ++$GLOBALS['num'] . "\n"; echo $node->value; }
// vérifie si le noeud courant a des enfants if($node->hasChildren()) { foreach($node->child as $child) { get_php($child); } } }
?>
|