phar.using.stream.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 54 行
HTML
54 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Using Phar Archives: the phar stream wrapper</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.using.html">Using Phar Archives</a></div> <div class="next" style="text-align: right; float: right;"><a href="phar.using.object.html">Using Phar Archives: the Phar and PharData class</a></div> <div class="up"><a href="phar.using.html">Using Phar Archives</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="phar.using.stream" class="section"> <h2 class="title">Using Phar Archives: the phar stream wrapper</h2> <p class="para"> The Phar stream wrapper fully supports <a href="function.fopen.html" class="function">fopen()</a> for read, write or append, <a href="function.unlink.html" class="function">unlink()</a>, <a href="function.stat.html" class="function">stat()</a>, <a href="function.fstat.html" class="function">fstat()</a>, <a href="function.fseek.html" class="function">fseek()</a>, <a href="function.rename.html" class="function">rename()</a> and directory stream operations <a href="function.opendir.html" class="function">opendir()</a> and as of version 2.0.0, <a href="function.rmdir.html" class="function">rmdir()</a> and <a href="function.mkdir.html" class="function">mkdir()</a>. </p> <p class="para"> Individual file compression and per-file metadata can also be manipulated in a Phar archive using stream contexts: </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 />$context </span><span style="color: #007700">= </span><span style="color: #0000BB">stream_context_create</span><span style="color: #007700">(array(</span><span style="color: #DD0000">'phar' </span><span style="color: #007700">=><br /> array(</span><span style="color: #DD0000">'compress' </span><span style="color: #007700">=> </span><span style="color: #0000BB">Phar</span><span style="color: #007700">::</span><span style="color: #0000BB">GZ</span><span style="color: #007700">)),<br /> array(</span><span style="color: #DD0000">'metadata' </span><span style="color: #007700">=> array(</span><span style="color: #DD0000">'user' </span><span style="color: #007700">=> </span><span style="color: #DD0000">'cellog'</span><span style="color: #007700">)));<br /></span><span style="color: #0000BB">file_put_contents</span><span style="color: #007700">(</span><span style="color: #DD0000">'phar://my.phar/somefile.php'</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">$context</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 does not operate on remote files, and cannot operate on remote files, and so is allowed even when the <a href="filesystem.configuration.html#ini.allow-url-fopen" class="link">allow_url_fopen</a> and <a href="filesystem.configuration.html#ini.allow-url-include" class="link">allow_url_include</a> INI options are disabled. </p> <p class="para"> Although it is possible to create phar archives from scratch just using stream operations, it is best to use the functionality built into the Phar class. The stream wrapper is best used for read-only operations. </p></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="phar.using.html">Using Phar Archives</a></div> <div class="next" style="text-align: right; float: right;"><a href="phar.using.object.html">Using Phar Archives: the Phar and PharData class</a></div> <div class="up"><a href="phar.using.html">Using Phar Archives</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?