📄 phar.fileformat.stub.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Phar file stub</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.fileformat.html">What makes a phar a phar and not a tar or a zip?</a></div> <div class="next" style="text-align: right; float: right;"><a href="phar.fileformat.comparison.html">Head-to-head comparison of Phar, Tar and Zip</a></div> <div class="up"><a href="phar.fileformat.html">What makes a phar a phar and not a tar or a zip?</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="phar.fileformat.stub" class="section"> <h2 class="title">Phar file stub</h2> <p class="para"> A Phar's stub is a simple PHP file. The smallest possible stub follows: </p> <p class="para"> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php </span><span style="color: #007700">__HALT_COMPILER();</span></span></code></div> </div> </p> <p class="para"> A stub must contain as a minimum, the <i>__HALT_COMPILER();</i> token at its conclusion. Typically, a stub will contain loader functionality like so: </p> <p class="para"> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />Phar</span><span style="color: #007700">::</span><span style="color: #0000BB">mapPhar</span><span style="color: #007700">();<br />include </span><span style="color: #DD0000">'phar://myphar.phar/index.php'</span><span style="color: #007700">;<br />__HALT_COMPILER();</span></span></code></div> </div> </p> <p class="para"> There are no restrictions on the contents of a Phar stub, except for the requirement that it conclude with <i>__HALT_COMPILER();</i>. The closing PHP tag <i><div class="cdata"><pre>?></pre></div></i> may be included or omitted, but there can be no more than 1 space between the <i>;</i> and the close tag <i><div class="cdata"><pre>?></pre></div></i> or the phar extension will be unable to process the Phar archive's manifest. </p> <p class="para"> In a tar or zip-based phar archive, the stub is stored in the <i>.phar/stub.php</i> file. The default stub for phar-based Phar archives contains approximately 7k of code to extract the contents of the phar and execute them. See <a href="phar.createdefaultstub.html" class="function">Phar::createDefaultStub()</a> for more detail. </p> <p class="para"> The phar alias is stored in a tar or zip-based phar archive in the <i>.phar/alias.txt</i> file as plain text. </p> </div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="phar.fileformat.html">What makes a phar a phar and not a tar or a zip?</a></div> <div class="next" style="text-align: right; float: right;"><a href="phar.fileformat.comparison.html">Head-to-head comparison of Phar, Tar and Zip</a></div> <div class="up"><a href="phar.fileformat.html">What makes a phar a phar and not a tar or a zip?</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 + -