function.tidynode-isphp.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 66 行
HTML
66 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Returns true if this node is PHP</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.tidynode-isjste.html">tidyNode->isJste</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.tidynode-istext.html">tidyNode->isText</a></div> <div class="up"><a href="ref.tidy.html">Tidy Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.tidynode-isphp" class="refentry"> <div class="refnamediv"> <h1 class="refname">tidyNode->isPhp</h1> <p class="verinfo">(No version information available, might be only in CVS)</p><p class="refpurpose"><span class="refname">tidyNode->isPhp</span> — <span class="dc-title">Returns true if this node is PHP</span></p> </div> <div class="refsect1 unknown"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><b><b>tidyNode->isPhp</b></b></span> ( <span class="methodparam">void</span> )</div> <p class="para rdfs-comment"> Returns <b><tt>TRUE</tt></b> if the current node is PHP code, <b><tt>FALSE</tt></b> otherwise. </p> <p class="para"> <div class="example"> <p><b>Example #1 get the PHP code from a mixed HTML/PHP document</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /><br />$html </span><span style="color: #007700">= <<< HTML<br /></span><span style="color: #0000BB"><html><head><br /><?php echo '<title>title</title>'; ?><br /></head><br /><body><br /><br /><?php<br />echo 'hello world!';<br />?><br /><br /></body></html><br /></span><span style="color: #007700">HTML;<br /><br /><br /></span><span style="color: #0000BB">$tidy </span><span style="color: #007700">= </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 </span><span style="color: #007700">= </span><span style="color: #0000BB">0</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">get_php</span><span style="color: #007700">(</span><span style="color: #0000BB">$tidy</span><span style="color: #007700">-></span><span style="color: #0000BB">html</span><span style="color: #007700">());<br /><br /><br />function </span><span style="color: #0000BB">get_php</span><span style="color: #007700">(</span><span style="color: #0000BB">$node</span><span style="color: #007700">) {<br /><br /> </span><span style="color: #FF8000">// check if the current node is PHP code<br /> </span><span style="color: #007700">if(</span><span style="color: #0000BB">$node</span><span style="color: #007700">-></span><span style="color: #0000BB">isPhp</span><span style="color: #007700">()) {<br /> echo </span><span style="color: #DD0000">"\n\n# PHP node #" </span><span style="color: #007700">. ++</span><span style="color: #0000BB">$GLOBALS</span><span style="color: #007700">[</span><span style="color: #DD0000">'num'</span><span style="color: #007700">] . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /> echo </span><span style="color: #0000BB">$node</span><span style="color: #007700">-></span><span style="color: #0000BB">value</span><span style="color: #007700">;<br /> }<br /><br /> </span><span style="color: #FF8000">// check if the current node has childrens<br /> </span><span style="color: #007700">if(</span><span style="color: #0000BB">$node</span><span style="color: #007700">-></span><span style="color: #0000BB">hasChildren</span><span style="color: #007700">()) {<br /> foreach(</span><span style="color: #0000BB">$node</span><span style="color: #007700">-></span><span style="color: #0000BB">child </span><span style="color: #007700">as </span><span style="color: #0000BB">$child</span><span style="color: #007700">) {<br /> </span><span style="color: #0000BB">get_php</span><span style="color: #007700">(</span><span style="color: #0000BB">$child</span><span style="color: #007700">);<br /> }<br /> }<br />}<br /><br /></span><span style="color: #0000BB">?></span></span></code></div> </div> <div class="example-contents"><p>The above example will output:</p></div> <div class="example-contents"><pre><div class="cdata"><pre># PHP node #1<?php echo '<title>title</title>'; ?># PHP node #2<?phpecho 'hello world!';?></pre></div> </pre></div> </div> </p> <blockquote><p><b class="note">Note</b>: This function was named <b>tidy_node->is_php()</b> in PHP 4/Tidy 1. <br /> </p></blockquote> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.tidynode-isjste.html">tidyNode->isJste</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.tidynode-istext.html">tidyNode->isText</a></div> <div class="up"><a href="ref.tidy.html">Tidy Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?