Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 12355

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Checks if a node is part of a HTML document</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="tidynode.iscomment.html">tidyNode::isComment</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="tidynode.isjste.html">tidyNode::isJste</a></div>
 <div class="up"><a href="class.tidynode.html">tidyNode</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="tidynode.ishtml" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">tidyNode::isHtml</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.0.1)</p><p class="refpurpose"><span class="refname">tidyNode::isHtml</span> &mdash; <span class="dc-title">Checks if a node is part of a HTML document</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-tidynode.ishtml-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>tidyNode::isHtml</strong></span>
    ( <span class="methodparam">void</span>
   )</div>

  <p class="para rdfs-comment">
   Tells if the node is part of HTML document.
  </p>
 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-tidynode.ishtml-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns <strong><code>TRUE</code></strong> if the node is part of a HTML document, <strong><code>FALSE</code></strong> otherwise.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-tidynode.ishtml-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-4065">
    <p><strong>Example #1 Extract HTML code from a mixed HTML document</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$html&nbsp;</span><span style="color: #007700">=&nbsp;&lt;&lt;&lt;&nbsp;HTML<br /></span><span style="color: #DD0000">&lt;html&gt;&lt;head&gt;<br />&lt;?php&nbsp;echo&nbsp;'&lt;title&gt;title&lt;/title&gt;';&nbsp;?&gt;<br />&lt;#&nbsp;<br />&nbsp;&nbsp;/*&nbsp;JSTE&nbsp;code&nbsp;*/<br />&nbsp;&nbsp;alert('Hello&nbsp;World');&nbsp;<br />#&gt;<br />&lt;/head&gt;<br />&lt;body&gt;<br /><br />&lt;?php<br />&nbsp;&nbsp;//&nbsp;PHP&nbsp;code<br />&nbsp;&nbsp;echo&nbsp;'hello&nbsp;world!';<br />?&gt;<br /><br />&lt;%<br />&nbsp;&nbsp;/*&nbsp;ASP&nbsp;code&nbsp;*/<br />&nbsp;&nbsp;response.write("Hello&nbsp;World!")<br />%&gt;<br /><br />&lt;!--&nbsp;Comments&nbsp;--&gt;<br />Hello&nbsp;World<br />&lt;/body&gt;&lt;/html&gt;<br />Outside&nbsp;HTML<br /></span><span style="color: #007700">HTML;<br /><br /><br /></span><span style="color: #0000BB">$tidy&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">tidy_parse_string</span><span style="color: #007700">(</span><span style="color: #0000BB">$html</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$num&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">get_nodes</span><span style="color: #007700">(</span><span style="color: #0000BB">$tidy</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">html</span><span style="color: #007700">());<br /><br />function&nbsp;</span><span style="color: #0000BB">get_nodes</span><span style="color: #007700">(</span><span style="color: #0000BB">$node</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;check&nbsp;if&nbsp;the&nbsp;current&nbsp;node&nbsp;is&nbsp;of&nbsp;requested&nbsp;type<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">if(</span><span style="color: #0000BB">$node</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">isHtml</span><span style="color: #007700">())&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"\n\n#&nbsp;html&nbsp;node&nbsp;#"&nbsp;</span><span style="color: #007700">.&nbsp;++</span><span style="color: #0000BB">$GLOBALS</span><span style="color: #007700">[</span><span style="color: #DD0000">'num'</span><span style="color: #007700">]&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$node</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">value</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;check&nbsp;if&nbsp;the&nbsp;current&nbsp;node&nbsp;has&nbsp;childrens<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">if(</span><span style="color: #0000BB">$node</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">hasChildren</span><span style="color: #007700">())&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach(</span><span style="color: #0000BB">$node</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">child&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$child</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">get_nodes</span><span style="color: #007700">(</span><span style="color: #0000BB">$child</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
# html node #1
&lt;html&gt;
&lt;head&gt;
&lt;?php echo &#039;&lt;title&gt;title&lt;/title&gt;&#039;; ?&gt;&lt;# 
  /* JSTE code */
  alert(&#039;Hello World&#039;); 
#&gt;
&lt;title&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;?php
  // PHP code
  echo &#039;hello world!&#039;;
?&gt;&lt;%
  /* ASP code */
  response.write(&quot;Hello World!&quot;)
%&gt;&lt;!-- Comments --&gt;
Hello WorldOutside HTML
&lt;/body&gt;
&lt;/html&gt;

# html node #2
&lt;head&gt;
&lt;?php echo &#039;&lt;title&gt;title&lt;/title&gt;&#039;; ?&gt;&lt;# 
  /* JSTE code */
  alert(&#039;Hello World&#039;); 
#&gt;
&lt;title&gt;&lt;/title&gt;
&lt;/head&gt;


# html node #3
&lt;?php echo &#039;&lt;title&gt;title&lt;/title&gt;&#039;; ?&gt;

# html node #4
&lt;# 
  /* JSTE code */
  alert(&#039;Hello World&#039;); 
#&gt;

# html node #5
&lt;title&gt;&lt;/title&gt;


# html node #6
&lt;body&gt;
&lt;?php
  // PHP code
  echo &#039;hello world!&#039;;
?&gt;&lt;%
  /* ASP code */
  response.write(&quot;Hello World!&quot;)
%&gt;&lt;!-- Comments --&gt;
Hello WorldOutside HTML
&lt;/body&gt;


# html node #7
&lt;?php
  // PHP code
  echo &#039;hello world!&#039;;
?&gt;

# html node #8
&lt;%
  /* ASP code */
  response.write(&quot;Hello World!&quot;)
%&gt;

# html node #9
&lt;!-- Comments --&gt;


# html node #10
Hello World

# html node #11
Outside HTML
</pre></div>
    </div>
   </div>
  </p>
 </div>

 
 <div class="refsect1 notes" id="refsect1-tidynode.ishtml-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    This function was named  <span class="function"><strong>tidy_node::is_html()</strong></span> in
    PHP 4/Tidy 1.
   </p>
  </p></blockquote>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="tidynode.iscomment.html">tidyNode::isComment</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="tidynode.isjste.html">tidyNode::isJste</a></div>
 <div class="up"><a href="class.tidynode.html">tidyNode</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>