1
0
mirror of https://github.com/php/doc-zh.git synced 2026-03-23 22:52:08 +01:00
Files
archived-doc-zh/language/operators/execution.xml
2025-12-10 23:31:28 +08:00

70 lines
1.9 KiB
XML
Raw Permalink 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.
<?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>