📄 phar.cancompress.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Returns whether phar extension supports compression using either zlib or bzip2</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.buildfromiterator.html">Phar::buildFromIterator</a></div> <div class="next" style="text-align: right; float: right;"><a href="phar.canwrite.html">Phar::canWrite</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.cancompress" class="refentry"> <div class="refnamediv"> <h1 class="refname">Phar::canCompress</h1> <p class="verinfo">(PECL phar:1.0.0-1.2.1)</p><p class="refpurpose"><span class="refname">Phar::canCompress</span> — <span class="dc-title">Returns whether phar extension supports compression using either zlib or bzip2</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><b><b>Phar::canCompress</b></b></span> ([ <span class="methodparam"><span class="type">int</span> <tt class="parameter">$type</tt></span> ] )</div> <p class="para rdfs-comment"> This should be used to test whether compression is possible prior to loading a phar archive containing compressed files. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">type</tt></i></span> <dd> <p class="para"> Either <i>Phar::GZ</i> or <i>Phar::BZ2</i> can be used to test whether compression is possible with a specific compression algorithm (zlib or bzip2). </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> <b><tt>TRUE</tt></b> if compression/decompression is available, <b><tt>FALSE</tt></b> if not. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 A <b>Phar::canCompress()</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: #007700">if (</span><span style="color: #0000BB">Phar</span><span style="color: #007700">::</span><span style="color: #0000BB">canCompress</span><span style="color: #007700">()) {<br /> echo </span><span style="color: #0000BB">file_get_contents</span><span style="color: #007700">(</span><span style="color: #DD0000">'phar://compressedphar.phar/internal/file.txt'</span><span style="color: #007700">);<br />} else {<br /> echo </span><span style="color: #DD0000">'no compression available'</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="pharfileinfo.getcompressedsize.html" class="function" rel="rdfs-seeAlso">PharFileInfo::getCompressedSize()</a></li> <li class="member"><a href="pharfileinfo.iscompressed.html" class="function" rel="rdfs-seeAlso">PharFileInfo::isCompressed()</a></li> <li class="member"><a href="pharfileinfo.compress.html" class="function" rel="rdfs-seeAlso">PharFileInfo::compress()</a></li> <li class="member"><a href="pharfileinfo.decompress.html" class="function" rel="rdfs-seeAlso">PharFileInfo::decompress()</a></li> <li class="member"><a href="phar.iscompressed.html" class="function" rel="rdfs-seeAlso">Phar::isCompressed()</a></li> <li class="member"><a href="phar.compressfiles.html" class="function" rel="rdfs-seeAlso">Phar::compressFiles()</a></li> <li class="member"><a href="phar.decompressfiles.html" class="function" rel="rdfs-seeAlso">Phar::decompressFiles()</a></li> <li class="member"><a href="phar.getsupportedcompression.html" class="function" rel="rdfs-seeAlso">Phar::getSupportedCompression()</a></li> <li class="member"><a href="phar.converttoexecutable.html" class="function" rel="rdfs-seeAlso">Phar::convertToExecutable()</a></li> <li class="member"><a href="phar.converttodata.html" class="function" rel="rdfs-seeAlso">Phar::convertToData()</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="phar.buildfromiterator.html">Phar::buildFromIterator</a></div> <div class="next" style="text-align: right; float: right;"><a href="phar.canwrite.html">Phar::canWrite</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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -