tidyNode::isJste

(PHP 5, PHP 7, PHP 8)

tidyNode::isJsteComprueba si el nodo es JSTE

Descripción

public function tidyNode::isJste(): bool

Indica si el nodo es JSTE.

Parámetros

Esta función no contiene ningún parámetro.

Valores devueltos

Devuelve true si el nodo es código JSTE, false de lo contrario.

Ejemplos

Ejemplo #1 Extrer el código JSTE de un documento HTML

<?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;

get_nodes($tidy->html());

function get_nodes($node) {

    // Verifica si el nodo actual es del tipo requerido
    if($node->isJste()) {
        echo "\n\n# jste node #" . ++$GLOBALS['num'] . "\n";
        echo $node->value;
    }

    // Verifica si el nodo actual tiene hijos
    if($node->hasChildren()) {
        foreach($node->child as $child) {
            get_nodes($child);
        }
    }
}

?>

El ejemplo anterior mostrará:

# jste node #1
<#
  /* código JSTE */
  alert('Hola Mundo');
#>

/*
var_dump($tidy->html()->child[0]->hasChildren());
var_dump($tidy->html()->child[0]->child[0]->hasChildren());
*/

add a note

User Contributed Notes

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