1
0
mirror of https://github.com/php/doc-ru.git synced 2026-03-27 09:12:07 +01:00
Files
archived-doc-ru/reference/exec/functions/exec.xml
2021-01-05 20:16:26 +03:00

154 lines
5.4 KiB
XML
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.
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 0c9c2dd669fe9395eaa73d487fbd160f9057429a Maintainer: aur Status: ready -->
<!-- Reviewed: yes Maintainer: lex -->
<!-- $Revision$ -->
<!-- splitted from ./en/functions/exec.xml, last change in rev 1.2 -->
<refentry xml:id="function.exec" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>exec</refname>
<refpurpose>Выполнить внешнюю программу</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type class="union"><type>string</type><type>false</type></type><methodname>exec</methodname>
<methodparam><type>string</type><parameter>command</parameter></methodparam>
<methodparam choice="opt"><type>array</type><parameter role="reference">output</parameter><initializer>&null;</initializer></methodparam>
<methodparam choice="opt"><type>int</type><parameter role="reference">result_code</parameter><initializer>&null;</initializer></methodparam>
</methodsynopsis>
<para>
<function>exec</function> выполняет команду
<parameter>command</parameter>.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>command</parameter></term>
<listitem>
<para>
Команда, которая будет исполнена.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>output</parameter></term>
<listitem>
<para>
Если параметр <parameter>output</parameter> указан, то
массив будет заполнен строками вывода программы.
Завершающие пробелы, такие как <literal>\n</literal>,
не будут включены в массив. Обратите внимание, что если массив уже содержит
какие-либо элементы, то <function>exec</function> добавит новые элементы в конец массива.
Если же вы не хотите, чтобы функция добавляла новые элементы в конец, вызовите
<function>unset</function> на этом массиве, прежде чем передать его в <function>exec</function>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>result_code</parameter></term>
<listitem>
<para>
Если аргумент <parameter>result_code</parameter> присутствует вместе с
<parameter>output</parameter>, тогда статус возврата выполненной команды
будет записан в этой переменной.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Последняя строка из результата команды. Если требуется
выполнить команду и получить все данные команды без какой-либо
обработки, используйте функцию <function>passthru</function>.
</para>
<para>
Возвращает &false; в случае возникновения ошибки.
</para>
<para>
Для получения результата выполнения команды, убедитесь, что параметр
<parameter>output</parameter> инициализирован и используется.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Пример функции <function>exec</function></title>
<programlisting role="php">
<![CDATA[
<?php
// выводит имя пользователя, от имени которого запущен процесс php/httpd
// (применимо к системам с командой "whoami" в системном пути)
$output=null;
$retval=null;
exec('whoami', $output, $retval);
echo "Вернёт статус $retval и значение:\n";
print_r($output);
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
Вернёт статус 0 и значение:
Array
(
[0] => cmb
)
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
&warn.escapeshell;
&note.exec-bg;
&note.exec-bypass-shell;
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>system</function></member>
<member><function>passthru</function></member>
<member><function>escapeshellcmd</function></member>
<member><function>pcntl_exec</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
-->