php-doc-en/reference/tidy/functions/tidy-node-isPhp.xml
Nuno Lopes 545db1e5ab added explanation about tidy constants
docs and examples


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@165940 c90b9560-bf6c-de11-be94-00142212c4b1
2004-08-10 17:01:18 +00:00

109 lines
2.1 KiB
XML

<?xml version='1.0' encoding='iso-8859-1'?>
<!-- $Revision: 1.4 $ -->
<refentry id="function.tidy-node-isPhp">
<refnamediv>
<refname>tidy_node->isPhp</refname>
<refpurpose>
Returns true if this node is PHP
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>tidy_node->isPhp</methodname>
<void/>
</methodsynopsis>
<para>
Returns &true; if the current node is PHP code, &false; otherwise.
</para>
<para>
<example>
<title>get the PHP code from a mixed HTML/PHP document</title>
<programlisting role="php">
<![CDATA[
<?php
$html = <<< HTML
<html><head>
<?php echo '<title>title</title>'; ?>
</head>
<body>
<?php
echo 'hello world!';
?>
</body></html>
HTML;
$tidy = tidy_parse_string($html);
$num = 0;
get_php($tidy->html());
function get_php($node) {
// check if the current node is PHP code
if($node->isPHP()) {
echo "\n\n# PHP node #" . ++$GLOBALS['num'] . "\n";
echo $node->value;
}
// check if the current node has childrens
if($node->hasChildren()) {
foreach($node->child as $child) {
get_php($child);
}
}
}
?>
]]>
</programlisting>
<para>
The above example will output:
</para>
<screen>
<![CDATA[
# PHP node #1
<?php echo '<title>title</title>'; ?>
# PHP node #2
<?php
echo 'hello world!';
?>
]]>
</screen>
</example>
</para>
<note>
<para>
This function was named <function>tidy_node->is_php</function> in
PHP 4/Tidy 1.
</para>
</note>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->