📄 phar.using.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Using Phar Archives</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.constants.html">Predefined Constants</a></div> <div class="next" style="text-align: right; float: right;"><a href="phar.using.stream.html">Using Phar Archives: the phar stream wrapper</a></div> <div class="up"><a href="book.phar.html">Phar</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div> <h1>Using Phar Archives</h1><h2>Table of Contents</h2><ul class="chunklist chunklist_chapter"><li><a href="phar.using.stream.html">Using Phar Archives: the phar stream wrapper</a></li><li><a href="phar.using.object.html">Using Phar Archives: the Phar and PharData class</a></li></ul> <div id="phar.using.intro" class="section"> <h2 class="title">Using Phar Archives: Introduction</h2> <p class="para"> Phar archives are similar in concept to Java JAR archives, but are tailored to the needs and to the flexibility of PHP applications. A Phar archive is used to distribute a complete PHP application or library in a single file. Unlike Java's implementation of JAR archives, no external tool is required to process or run a PHP Phar archive. A Phar archive application is used exactly like any other PHP application: </p> <div class="example-contents"><pre> <div class="cdata"><pre>php coolapplication.phar </pre></div> </pre></div> <p class="para"> Using a Phar archive library is identical to using any other PHP library: </p> <p class="para"> <div class="informalexample"> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /></span><span style="color: #007700">include </span><span style="color: #DD0000">'coollibrary.phar'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> <p class="para"> The <i>phar</i> stream wrapper provides the core of the phar extension, and is explained in detail <a href="phar.using.stream.html" class="link">here</a>. The phar stream wrapper allows accessing the files within a phar archive using PHP's standard file functions <a href="function.fopen.html" class="function">fopen()</a>, <a href="function.opendir.html" class="function">opendir()</a>, and others that work on regular files. The <i>phar</i> stream wrapper supports all read/write operations on both files and directories. </p> <p class="para"> <div class="informalexample"> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /></span><span style="color: #007700">include </span><span style="color: #DD0000">'phar://coollibrary.phar/internal/file.php'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">'Content-type: image/jpeg'</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">// phars can be accessed by full path or by alias<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">file_get_contents</span><span style="color: #007700">(</span><span style="color: #DD0000">'phar:///fullpath/to/coollibrary.phar/images/wow.jpg'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> <p class="para"> The <a href="class.Phar.html" class="classname">Phar</a> class implements advanced functionality for accessing files and for creating phar archives. The Phar class is explained in detail <a href="phar.using.object.html" class="link">here</a>. </p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -