-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathexecution.xml
More file actions
69 lines (67 loc) · 1.9 KB
/
execution.xml
File metadata and controls
69 lines (67 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: eb8957c4fd67d7bd458140e1bc0588834ab49b3e Maintainer: mowangjuanzi Status: ready -->
<!-- CREDITS: Luffy -->
<sect1 xml:id="language.operators.execution">
<title>执行运算符</title>
<titleabbrev>执行</titleabbrev>
<para>
PHP 支持一个执行运算符:反引号(<literal>``</literal>)。注意这不是单引号!PHP
将尝试将反引号中的内容作为 shell 命令来执行,并将其输出信息返回(即,可以赋给一个变量而不是简单地丢弃到标准输出)。使用反引号运算符“`”的效果与函数
<function>shell_exec</function> 相同。
</para>
<para>
<example>
<title>反引号运算符</title>
<programlisting role="php" annotations="non-interactive">
<![CDATA[
<?php
$output = `ls -al`;
echo "<pre>$output</pre>";
?>
]]>
</programlisting>
</example>
</para>
<note>
<para>
关闭了 <function>shell_exec</function> 时反引号运算符是无效的。
</para>
</note>
<note>
<para>
与其它某些语言不同,反引号不能在双引号字符串中使用。
</para>
</note>
<sect2 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>8.5.0</entry>
<entry>
已弃用将反引号运算符作为 <function>shell_exec</function> 的别名。
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</sect2>
<sect2 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><link linkend="ref.exec">程序执行函数</link></member>
<member><function>popen</function></member>
<member><function>proc_open</function></member>
<member><link linkend="features.commandline">PHP 的命令行模式</link></member>
</simplelist>
</para>
</sect2>
</sect1>