phar.count.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 78 行
HTML
78 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Returns the number of entries (files) in the Phar archive</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="phar.copy.html">Phar::copy</a></div> <div class="next" style="text-align: right; float: right;"><a href="phar.createdefaultstub.html">Phar::createDefaultStub</a></div> <div class="up"><a href="class.Phar.html">Phar</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="phar.count" class="refentry"> <div class="refnamediv"> <h1 class="refname">Phar::count</h1> <p class="verinfo">(PECL phar:1.0.0-1.2.1)</p><p class="refpurpose"><span class="refname">Phar::count</span> — <span class="dc-title">Returns the number of entries (files) in the Phar archive</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">int</span> <span class="methodname"><b><b>Phar::count</b></b></span> ( <span class="methodparam">void</span> )</div> <p class="para rdfs-comment"> </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> The number of files contained within this phar, or <i>0</i> (the number zero) if none. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 A <b>Phar::count()</b> example</b></p> <div class="example-contents"><p> </p></div> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">// make sure it doesn't exist<br /></span><span style="color: #007700">@</span><span style="color: #0000BB">unlink</span><span style="color: #007700">(</span><span style="color: #DD0000">'brandnewphar.phar'</span><span style="color: #007700">);<br />try {<br /> </span><span style="color: #0000BB">$p </span><span style="color: #007700">= new </span><span style="color: #0000BB">Phar</span><span style="color: #007700">(</span><span style="color: #0000BB">dirname</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">) . </span><span style="color: #DD0000">'/brandnewphar.phar'</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #DD0000">'brandnewphar.phar'</span><span style="color: #007700">);<br />} catch (</span><span style="color: #0000BB">Exception $e</span><span style="color: #007700">) {<br /> echo </span><span style="color: #DD0000">'Could not create phar:'</span><span style="color: #007700">, </span><span style="color: #0000BB">$e</span><span style="color: #007700">;<br />}<br />echo </span><span style="color: #DD0000">'The new phar has ' </span><span style="color: #007700">. </span><span style="color: #0000BB">$p</span><span style="color: #007700">-></span><span style="color: #0000BB">count</span><span style="color: #007700">() . </span><span style="color: #DD0000">" entries\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$p</span><span style="color: #007700">[</span><span style="color: #DD0000">'file.txt'</span><span style="color: #007700">] = </span><span style="color: #DD0000">'hi'</span><span style="color: #007700">;<br />echo </span><span style="color: #DD0000">'The new phar has ' </span><span style="color: #007700">. </span><span style="color: #0000BB">$p</span><span style="color: #007700">-></span><span style="color: #0000BB">count</span><span style="color: #007700">() . </span><span style="color: #DD0000">" entries\n"</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>The new phar has 0 entriesThe new phar has 1 entries</pre></div> </pre></div> </div> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="phar.copy.html">Phar::copy</a></div> <div class="next" style="text-align: right; float: right;"><a href="phar.createdefaultstub.html">Phar::createDefaultStub</a></div> <div class="up"><a href="class.Phar.html">Phar</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?