📄 function.php-strip-whitespace.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Return source with stripped comments and whitespace</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.php-check-syntax.html">php_check_syntax</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.show-source.html">show_source</a></div> <div class="up"><a href="ref.misc.html">Misc. Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.php-strip-whitespace" class="refentry"> <div class="refnamediv"> <h1 class="refname">php_strip_whitespace</h1> <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">php_strip_whitespace</span> — <span class="dc-title">Return source with stripped comments and whitespace</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">string</span> <span class="methodname"><b><b>php_strip_whitespace</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$filename</tt></span> )</div> <p class="para rdfs-comment"> Returns the PHP source code in <i><tt class="parameter">filename</tt></i> with PHP comments and whitespace removed. This may be useful for determining the amount of actual code in your scripts compared with the amount of comments. This is similar to using <strong class="command">php -w</strong> from the <a href="features.commandline.html" class="link">commandline</a>. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">filename</tt></i></span> <dd> <p class="para"> Path to the PHP file. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> The stripped source code will be returned on success, or an empty string on failure. </p> <blockquote><p><b class="note">Note</b>: This function works as described as of PHP 5.0.1. Before this it would only return an empty string. For more information on this bug and its prior behavior, see bug report <a href="http://bugs.php.net/29606" class="link external">» #29606</a>. <br /> </p></blockquote> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 <b>php_strip_whitespace()</b> example</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">// PHP comment here<br /><br />/*<br /> * Another PHP comment<br /> */<br /><br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">php_strip_whitespace</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">// Newlines are considered whitespace, and are removed too:<br /></span><span style="color: #0000BB">do_nothing</span><span style="color: #007700">();<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 echo php_strip_whitespace(__FILE__); do_nothing(); ?></pre></div> </pre></div> <div class="example-contents"><p> Notice the PHP comments are gone, as are the whitespace and newline after the first echo statement. </p></div> </div> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.php-check-syntax.html">php_check_syntax</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.show-source.html">show_source</a></div> <div class="up"><a href="ref.misc.html">Misc. Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -