uTools-Manuals/docs/php/escapeshellarg.html
2019-04-28 19:00:34 +08:00

90 lines
4.0 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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>把字符串转码为可以在 shell 命令里使用的参数</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.escapeshellarg" class="refentry">
<div class="refnamediv">
<h1 class="refname">escapeshellarg</h1>
<p class="verinfo">(PHP 4 &gt;= 4.0.3, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">escapeshellarg</span> &mdash; <span class="dc-title">把字符串转码为可以在 shell 命令里使用的参数</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.escapeshellarg-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>escapeshellarg</strong></span>
( <span class="methodparam"><span class="type">string</span> <code class="parameter">$arg</code></span>
) : <span class="type">string</span></div>
<p class="para rdfs-comment">
<span class="function"><strong>escapeshellarg()</strong></span> 将给字符串增加一个单引号并且能引用或者转码任何已经存在的单引号,这样以确保能够直接将一个字符串传入 shell 函数并且还是确保安全的。对于用户输入的部分参数就应该使用这个函数。shell 函数包含 <span class="function"><a href="exec.html" class="function">exec()</a></span>, <span class="function"><a href="system.html" class="function">system()</a></span>
<a href="language.operators.execution.html" class="link">执行运算符</a>
</p>
</div>
<div class="refsect1 parameters" id="refsect1-function.escapeshellarg-parameters">
<h3 class="title">参数</h3>
<p class="para">
<dl>
<dt>
<code class="parameter">arg</code></dt>
<dd>
<p class="para">
需要被转码的参数。
</p>
</dd>
</dl>
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.escapeshellarg-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
转换之后字符串。
</p>
</div>
<div class="refsect1 examples" id="refsect1-function.escapeshellarg-examples">
<h3 class="title">范例</h3>
<p class="para">
<div class="example" id="example-4357">
<p><strong>Example #1 <span class="function"><strong>escapeshellarg()</strong></span> 的例子</strong></p>
<div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />system</span><span style="color: #007700">(</span><span style="color: #DD0000">'ls&nbsp;'</span><span style="color: #007700">.</span><span style="color: #0000BB">escapeshellarg</span><span style="color: #007700">(</span><span style="color: #0000BB">$dir</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
</div>
</div>
</p>
</div>
<div class="refsect1 seealso" id="refsect1-function.escapeshellarg-seealso">
<h3 class="title">参见</h3>
<p class="para">
<ul class="simplelist">
<li class="member"><span class="function"><a href="escapeshellcmd.html" class="function" rel="rdfs-seeAlso">escapeshellcmd()</a> - shell 元字符转义</span></li>
<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="popen.html" class="function" rel="rdfs-seeAlso">popen()</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"><a href="language.operators.execution.html" class="link">执行运算符</a></li>
</ul>
</p>
</div>
</div></div></div></body></html>