mirror of
https://github.com/php/doc-zh.git
synced 2026-03-24 15:12:20 +01:00
101 lines
3.0 KiB
XML
101 lines
3.0 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
||
<!-- $Revision$ -->
|
||
<!-- EN-Revision: 60c391265d2a51003e1ed0952e5a2413f81c7fc2 Maintainer: zhoumengkang Status: ready -->
|
||
<!-- splitted from ./en/functions/exec.xml, last change in rev 1.8 -->
|
||
<refentry xml:id="function.escapeshellarg" xmlns="http://docbook.org/ns/docbook">
|
||
<refnamediv>
|
||
<refname>escapeshellarg</refname>
|
||
<refpurpose>把字符串转义为可以在 shell 命令里使用的参数</refpurpose>
|
||
</refnamediv>
|
||
|
||
<refsect1 role="description">
|
||
&reftitle.description;
|
||
<methodsynopsis>
|
||
<type>string</type><methodname>escapeshellarg</methodname>
|
||
<methodparam><type>string</type><parameter>arg</parameter></methodparam>
|
||
</methodsynopsis>
|
||
<para>
|
||
<function>escapeshellarg</function> 将给字符串增加一个单引号并且能引用或者转义任何已经存在的单引号,这样以确保能够直接将一个字符串传入 shell
|
||
函数,并且还是确保安全的。对于用户输入的部分参数就应该使用这个函数。shell 函数包含<function>exec</function>、<function>system</function>
|
||
和<link linkend="language.operators.execution">执行运算符</link> 。
|
||
</para>
|
||
<para>
|
||
在 Windows 上,<function>escapeshellarg</function>
|
||
用空格替换了百分号、感叹号(延迟变量替换)和双引号,并在字符串两边加上双引号。此外,每条连续的反斜线(<literal>\</literal>)都会被一个额外的反斜线所转义。
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="parameters">
|
||
&reftitle.parameters;
|
||
<para>
|
||
<variablelist>
|
||
<varlistentry>
|
||
<term><parameter>arg</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
需要被转义的参数。
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
</variablelist>
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="returnvalues">
|
||
&reftitle.returnvalues;
|
||
<para>
|
||
转换之后字符串。
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="examples">
|
||
&reftitle.examples;
|
||
<para>
|
||
<example>
|
||
<title><function>escapeshellarg</function> 的例子</title>
|
||
<programlisting role="php">
|
||
<![CDATA[
|
||
<?php
|
||
system('ls '.escapeshellarg($dir));
|
||
?>
|
||
]]>
|
||
</programlisting>
|
||
</example>
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="seealso">
|
||
&reftitle.seealso;
|
||
<para>
|
||
<simplelist>
|
||
<member><function>escapeshellcmd</function></member>
|
||
<member><function>exec</function></member>
|
||
<member><function>popen</function></member>
|
||
<member><function>system</function></member>
|
||
<member><link linkend="language.operators.execution">执行运算符</link></member>
|
||
</simplelist>
|
||
</para>
|
||
</refsect1>
|
||
</refentry>
|
||
|
||
<!-- Keep this comment at the end of the file
|
||
Local variables:
|
||
mode: sgml
|
||
sgml-omittag:t
|
||
sgml-shorttag:t
|
||
sgml-minimize-attributes:nil
|
||
sgml-always-quote-attributes:t
|
||
sgml-indent-step:1
|
||
sgml-indent-data:t
|
||
indent-tabs-mode:nil
|
||
sgml-parent-document:nil
|
||
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
||
sgml-exposed-tags:nil
|
||
sgml-local-catalogs:nil
|
||
sgml-local-ecat-files:nil
|
||
End:
|
||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||
vim: et tw=78 syn=sgml
|
||
vi: ts=1 sw=1
|
||
-->
|