mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 05:26:57 +08:00
111 lines
5.2 KiB
HTML
111 lines
5.2 KiB
HTML
<!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>执行外部程序并且显示原始输出</title>
|
||
</head>
|
||
<body class="docs"><div id="layout">
|
||
<div id="layout-content"><div id="function.passthru" class="refentry">
|
||
<div class="refnamediv">
|
||
<h1 class="refname">passthru</h1>
|
||
<p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">passthru</span> — <span class="dc-title">执行外部程序并且显示原始输出</span></p>
|
||
|
||
</div>
|
||
|
||
<div class="refsect1 description" id="refsect1-function.passthru-description">
|
||
<h3 class="title">说明</h3>
|
||
<div class="methodsynopsis dc-description">
|
||
<span class="methodname"><strong>passthru</strong></span>
|
||
( <span class="methodparam"><span class="type">string</span> <code class="parameter">$command</code></span>
|
||
[, <span class="methodparam"><span class="type">int</span> <code class="parameter reference">&$return_var</code></span>
|
||
] ) : <span class="type"><span class="type void">void</span></span></div>
|
||
|
||
<p class="para rdfs-comment">
|
||
同 <span class="function"><a href="exec.html" class="function">exec()</a></span> 函数类似,
|
||
<span class="function"><strong>passthru()</strong></span> 函数
|
||
也是用来执行外部命令(<code class="parameter">command</code>)的。
|
||
当所执行的 Unix 命令输出二进制数据,
|
||
并且需要直接传送到浏览器的时候,
|
||
需要用此函数来替代 <span class="function"><a href="exec.html" class="function">exec()</a></span>
|
||
或 <span class="function"><a href="system.html" class="function">system()</a></span> 函数。
|
||
常用来执行诸如 pbmplus 之类的可以直接输出图像流的命令。
|
||
通过设置 Content-type 为 <em>image/gif</em>,
|
||
然后调用 pbmplus 程序输出 gif 文件,
|
||
就可以从 PHP 脚本中直接输出图像到浏览器。
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 parameters" id="refsect1-function.passthru-parameters">
|
||
<h3 class="title">参数</h3>
|
||
<p class="para">
|
||
<dl>
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">command</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
要执行的命令。
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">return_var</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
如果提供 <code class="parameter">return_var</code> 参数,
|
||
Unix 命令的返回状态会被记录到此参数。
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
</dl>
|
||
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 returnvalues" id="refsect1-function.passthru-returnvalues">
|
||
<h3 class="title">返回值</h3>
|
||
<p class="para">
|
||
没有返回值。
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 notes" id="refsect1-function.passthru-notes">
|
||
<h3 class="title">注释</h3>
|
||
<div class="warning"><strong class="warning">Warning</strong><p class="para">当用户提供的数据传入此函数,使用
|
||
<span class="function"><a href="escapeshellarg.html" class="function">escapeshellarg()</a></span> 或 <span class="function"><a href="escapeshellcmd.html" class="function">escapeshellcmd()</a></span>
|
||
来确保用户欺骗系统从而执行任意命令。</p></div>
|
||
<blockquote class="note"><p><strong class="note">Note</strong>: <p class="para">如何程序使用此函数启动,为了能保持在后台运行,此程序必须将输出重定向到文件或其它输出流。否则会导致
|
||
PHP 挂起,直至程序执行结束。</p></p></blockquote>
|
||
<blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara"><a href="features.safe_mode.html" class="link">安全模式</a> 启用时,可仅可用
|
||
<a href="ini.sect.safe-mode.html#ini.safe-mode-exec-dir" class="link">safe_mode_exec_dir</a> 执行文件。实际上,现在不允许在到可执行的路径中存在 <em>..</em> 组件。</span></p></blockquote>
|
||
<div class="warning"><strong class="warning">Warning</strong><p class="simpara"><a href="features.safe_mode.html" class="link">安全模式</a> 启用时,命令字符串会被
|
||
<span class="function"><a href="escapeshellcmd.html" class="function">escapeshellcmd()</a></span> 转换。因此,<em>echo y | echo x</em> 会变成
|
||
<em>echo y \| echo x</em>。</p></div>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 seealso" id="refsect1-function.passthru-seealso">
|
||
<h3 class="title">参见</h3>
|
||
<p class="para">
|
||
<ul class="simplelist">
|
||
<li class="member"><span class="function"><a href="exec.html" class="function" rel="rdfs-seeAlso">exec()</a> - 执行一个外部程序</span></li>
|
||
<li class="member"><span class="function"><a href="system.html" class="function" rel="rdfs-seeAlso">system()</a> - 执行外部程序,并且显示输出</span></li>
|
||
<li class="member"><span class="function"><a href="popen.html" class="function" rel="rdfs-seeAlso">popen()</a> - 打开进程文件指针</span></li>
|
||
<li class="member"><span class="function"><a href="escapeshellcmd.html" class="function" rel="rdfs-seeAlso">escapeshellcmd()</a> - shell 元字符转义</span></li>
|
||
<li class="member"><a href="language.operators.execution.html" class="link">执行运算符</a></li>
|
||
</ul>
|
||
</p>
|
||
</div>
|
||
|
||
</div></div></div></body></html> |