<!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>Returns whether phar extension supports compression using either zlib or bzip2</title> </head> <body><div class="manualnavbar" 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">(PHP >= 5.3.0, PECL phar >= 1.0.0)</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" id="refsect1-phar.cancompress-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">final</span> <span class="modifier">public</span> <span class="modifier">static</span> <span class="type">bool</span> <span class="methodname"><strong>Phar::canCompress</strong></span> ([ <span class="methodparam"><span class="type">int</span> <code class="parameter">$type</code><span class="initializer"> = 0</span></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" id="refsect1-phar.cancompress-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">type</code></em></span> <dd> <p class="para"> Either <em>Phar::GZ</em> or <em>Phar::BZ2</em> 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" id="refsect1-phar.cancompress-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> <strong><code>TRUE</code></strong> if compression/decompression is available, <strong><code>FALSE</code></strong> if not. </p> </div> <div class="refsect1 examples" id="refsect1-phar.cancompress-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-663"> <p><strong>Example #1 A <span class="function"><strong>Phar::canCompress()</strong></span> example</strong></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" id="refsect1-phar.cancompress-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="pharfileinfo.getcompressedsize.html" class="function" rel="rdfs-seeAlso">PharFileInfo::getCompressedSize()</a> - Returns the actual size of the file (with compression) inside the Phar archive</span></li> <li class="member"> <span class="function"><a href="pharfileinfo.iscompressed.html" class="function" rel="rdfs-seeAlso">PharFileInfo::isCompressed()</a> - Returns whether the entry is compressed</span></li> <li class="member"> <span class="function"><a href="pharfileinfo.compress.html" class="function" rel="rdfs-seeAlso">PharFileInfo::compress()</a> - Compresses the current Phar entry with either zlib or bzip2 compression</span></li> <li class="member"> <span class="function"><a href="pharfileinfo.decompress.html" class="function" rel="rdfs-seeAlso">PharFileInfo::decompress()</a> - Decompresses the current Phar entry within the phar</span></li> <li class="member"> <span class="function"><a href="phar.iscompressed.html" class="function" rel="rdfs-seeAlso">Phar::isCompressed()</a> - Returns Phar::GZ or PHAR::BZ2 if the entire phar archive is compressed (.tar.gz/tar.bz and so on)</span></li> <li class="member"> <span class="function"><a href="phar.compressfiles.html" class="function" rel="rdfs-seeAlso">Phar::compressFiles()</a> - Compresses all files in the current Phar archive</span></li> <li class="member"> <span class="function"><a href="phar.decompressfiles.html" class="function" rel="rdfs-seeAlso">Phar::decompressFiles()</a> - Decompresses all files in the current Phar archive</span></li> <li class="member"> <span class="function"><a href="phar.getsupportedcompression.html" class="function" rel="rdfs-seeAlso">Phar::getSupportedCompression()</a> - Return array of supported compression algorithms</span></li> <li class="member"> <span class="function"><a href="phar.converttoexecutable.html" class="function" rel="rdfs-seeAlso">Phar::convertToExecutable()</a> - Convert a phar archive to another executable phar archive file format</span></li> <li class="member"> <span class="function"><a href="phar.converttodata.html" class="function" rel="rdfs-seeAlso">Phar::convertToData()</a> - Convert a phar archive to a non-executable tar or zip file</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" 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>