📄 phar.interceptfilefuncs.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>instructs phar to intercept fopen, file_get_contents, opendir, and all of the stat-related functions</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.hasmetadata.html">Phar::hasMetaData</a></div> <div class="next" style="text-align: right; float: right;"><a href="phar.isbuffering.html">Phar::isBuffering</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.interceptfilefuncs" class="refentry"> <div class="refnamediv"> <h1 class="refname">Phar::interceptFileFuncs</h1> <p class="verinfo">(No version information available, might be only in CVS)</p><p class="refpurpose"><span class="refname">Phar::interceptFileFuncs</span> — <span class="dc-title">instructs phar to intercept fopen, file_get_contents, opendir, and all of the stat-related functions</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type"><span class="type void">void</span></span> <span class="methodname"><b><b>Phar::interceptFileFuncs</b></b></span> ( <span class="methodparam">void</span> )</div> <p class="para rdfs-comment"> instructs phar to intercept <a href="function.fopen.html" class="function">fopen()</a>, <a href="function.readfile.html" class="function">readfile()</a>, <a href="function.file-get-contents.html" class="function">file_get_contents()</a>, <a href="function.opendir.html" class="function">opendir()</a>, and all of the stat-related functions. If any of these functions is called from within a phar archive with a relative path, the call is modified to access a file within the phar archive. Absolute paths are assumed to be attempts to load external files from the filesystem. </p> <p class="para"> This function makes it possible to run PHP applications designed to run off of a hard disk as a phar application. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> No parameters. </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 A <b>Phar::interceptFileFuncs()</b> example</b></p> <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">interceptFileFuncs</span><span style="color: #007700">();<br />include </span><span style="color: #DD0000">'phar://' </span><span style="color: #007700">. </span><span style="color: #0000BB">__FILE__ </span><span style="color: #007700">. </span><span style="color: #DD0000">'/file.php'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> <p class="para"> Assuming that this phar is at <i>/path/to/myphar.phar</i> and it contains <i>file.php</i> and <i>file2.txt</i>, if <i>file.php</i> contains this code: </p> <p class="para"> <div class="example"> <p><b>Example #2 A <b>Phar::interceptFileFuncs()</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">echo </span><span style="color: #0000BB">file_get_contents</span><span style="color: #007700">(</span><span style="color: #DD0000">'file2.txt'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> <p class="para"> Normally PHP would search the current directory for <i>file2.txt</i>, which would translate as the directory of file.php, or the current directory of a command-line user. <b>Phar::interceptFileFuncs()</b> instructs PHP to consider the current directory to be <i>phar:///path/to/myphar.phar/</i> and so opens <i>phar:///path/to/myphar.phar/file2.txt</i> in the above example code. </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="phar.hasmetadata.html">Phar::hasMetaData</a></div> <div class="next" style="text-align: right; float: right;"><a href="phar.isbuffering.html">Phar::isBuffering</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 + -