mirror of
https://github.com/php/doc-es.git
synced 2026-03-26 16:32:13 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@334774 c90b9560-bf6c-de11-be94-00142212c4b1
150 lines
4.4 KiB
XML
150 lines
4.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 14af302c9c0e561fa6f9cdd956268758ba9a89c5 Maintainer: jesusruiz 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>Parchear una cadena con un diff unificado</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>
|
|
Parchea una cadena <parameter>str</parameter> con un parche unificado en parámetro <parameter>patch</parameter>
|
|
y devuelve el resultado. <parameter>patch</parameter> tiene que ser un diff unificado creado por la función
|
|
<function>xdiff_file_diff</function>/<function>xdiff_string_diff</function>.
|
|
Un parámetro opcional <parameter>flags</parameter> especifica el modo de operación. Cualquier
|
|
fragmento erróneo del parche será almacenado en el interior de la variable <parameter>error</parameter> si
|
|
si esta es proporcionada.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>str</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
La cadena original.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>patch</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
La cadena parche unificada. Esta tiene que ser creada utilizando las funciones <function>xdiff_string_diff</function>,
|
|
<function>xdiff_file_diff</function> o herramientas compatibles.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>flags</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
<parameter>flags</parameter> uede ser
|
|
<constant>XDIFF_PATCH_NORMAL</constant> (modo por defecto, parche normal)
|
|
o <constant>XDIFF_PATCH_REVERSE</constant> (parche invertido).
|
|
</para>
|
|
<para>
|
|
A partir de la versión 1.5.0, también se puede utilizar binario OR para habilitar el indicador
|
|
<constant>XDIFF_PATCH_IGNORESPACE</constant>.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>error</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Si se proporciona entonces los fragmentos erróneos se almacenan dentro de esta variable.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Devuelve la cadena parcheada, o &false; en caso de error.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Ejemplo de <function>xdiff_string_patch</function></title>
|
|
<para>
|
|
El siguiente código aplica cambios en algún artículo.
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$old_article = file_get_contents('./old_article.txt');
|
|
$diff = $_SERVER['patch']; /* Supongamos que alguien pega un parche para un formulario html */
|
|
|
|
$errors = '';
|
|
|
|
$new_article = xdiff_string_patch($old_article, $diff, XDIFF_PATCH_NORMAL, $errors);
|
|
if (is_string($new_article)) {
|
|
echo "Nuevo artículo:\n";
|
|
echo $new_article;
|
|
}
|
|
|
|
if (strlen($errors)) {
|
|
echo "Fragmentos erróneos: \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
|
|
-->
|