1
0
mirror of https://github.com/php/doc-ru.git synced 2026-03-26 16:52:12 +01:00
Files
archived-doc-ru/reference/xdiff/functions/xdiff-string-patch.xml
Sergey Panteleev daef8df962 Обнуление тега Reviewed (#364)
[skip-lint]
[skip-spellcheck]
2021-11-16 13:03:53 +03:00

149 lines
4.9 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: e41806c30bf6975e452c0d4ce35ab0984c2fa68c Maintainer: rjhdby Status: ready -->
<!-- Reviewed: no -->
<!-- Generated by xml_proto.php v2.0. Found in /scripts directory of phpdoc. -->
<refentry xml:id="function.xdiff-string-patch" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>xdiff_string_patch</refname>
<refpurpose>Применить обычный патч к строке</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>xdiff_string_patch</methodname>
<methodparam><type>string</type><parameter>str</parameter></methodparam>
<methodparam><type>string</type><parameter>patch</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>flags</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter role="reference">error</parameter></methodparam>
</methodsynopsis>
<para>
Применяет к строке <parameter>str</parameter> обычный патч
<parameter>patch</parameter> и возвращает результат.
<parameter>patch</parameter> должен быть обычным патчем, созданным с помощью
функций <function>xdiff_file_diff</function> или <function>xdiff_string_diff</function>.
Опциональный параметр <parameter>flags</parameter> задаёт режим операции.
Все отвергнутые части патча будут записаны в переменную <parameter>error</parameter>.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>str</parameter></term>
<listitem>
<para>
Оригинальная строка.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>patch</parameter></term>
<listitem>
<para>
Стандартный патч. Должен быть создан функциями <function>xdiff_string_diff</function>,
или <function>xdiff_file_diff</function>, либо с помощью инструментов, создающих
совместимые патчи.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>flags</parameter></term>
<listitem>
<para>
<parameter>flags</parameter> может быть
<constant>XDIFF_PATCH_NORMAL</constant> (режим по умолчанию, нормальный патч)
или <constant>XDIFF_PATCH_REVERSE</constant> (реверсивный патч).
</para>
<para>
Начиная с версии 1.5.0 можно использовать бинарное ИЛИ для добавления
флага <constant>XDIFF_PATCH_IGNORESPACE</constant>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>error</parameter></term>
<listitem>
<para>
Если задан, то в эту переменную будут записаны все отвергнутые части патча.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Возвращает строку, либо &false; в случае возникновения ошибке.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Пример использования <function>xdiff_string_patch</function></title>
<para>
Следующий код применяет патч к статье.
</para>
<programlisting role="php">
<![CDATA[
<?php
$old_article = file_get_contents('./old_article.txt');
$diff = $_SERVER['patch']; /* Допустим кто-то отправил патч через html-форму */
$errors = '';
$new_article = xdiff_string_patch($old_article, $diff, XDIFF_PATCH_NORMAL, $errors);
if (is_string($new_article)) {
echo "Новая статья:\n";
echo $new_article;
}
if (strlen($errors)) {
echo "Отклонены: \n";
echo $errors;
}
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>xdiff_string_diff</function></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
-->