mirror of
https://github.com/php/doc-es.git
synced 2026-03-24 07:22:16 +01:00
146 lines
4.3 KiB
XML
146 lines
4.3 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- EN-Revision: 4754397753fd79f1c846868b66a2448babab1c54 Maintainer: andresdzphp Status: ready -->
|
|
<!-- Reviewed: yes Maintainer: andresdzphp -->
|
|
|
|
<!-- Generated by xml_proto.php v2.0. Found in /scripts directory of phpdoc. -->
|
|
<refentry xml:id="function.xdiff-string-diff" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>xdiff_string_diff</refname>
|
|
<refpurpose>Hacer un diff unificado de dos strings</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>string</type><methodname>xdiff_string_diff</methodname>
|
|
<methodparam><type>string</type><parameter>old_data</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>new_data</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>context</parameter><initializer>3</initializer></methodparam>
|
|
<methodparam choice="opt"><type>bool</type><parameter>minimal</parameter><initializer>&false;</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Hace un diff unificado que contiene diferencias entre el string <parameter>old_data</parameter> y
|
|
el string <parameter>new_data</parameter> y devuelve este. El diff resultante es legible.
|
|
Un parámetro opcional <parameter>context</parameter> especifica el número de líneas de contexto que hay que añadir
|
|
alrededor de cada cambio. Establecer el parámetro <parameter>minimal</parameter>
|
|
a true dará como resultado de salida el archivo parche más corto posible (puede tomar algo de tiempo).
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>old_data</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Primera cadena con información. Esta actúa como "vieja" información.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>new_data</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Segundo string con información. Esta actúa como "nueva" información.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>context</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Indica el número de líneas de contexto que desea incluir en el diff
|
|
resultado.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>minimal</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Establezca este parámetro a &true; si desea reducir el tamaño del
|
|
resultado (puede tomar algo de tiempo).
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Devuelve un string con el resultado diff o &false; si ocurriera un error interno.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Ejemplo de <function>xdiff_string_diff</function></title>
|
|
<para>
|
|
El siguiente código hace un diff unificado de dos artículos.
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$old_article = file_get_contents('./old_article.txt');
|
|
$new_article = $_REQUEST['article']; /* Supongamos que alguien pega un nuevo artículo en formato html */
|
|
|
|
$diff = xdiff_string_diff($old_article, $new_article, 1);
|
|
if (is_string($diff)) {
|
|
echo "Diferencias entre los dos artículos:\n";
|
|
echo $diff;
|
|
}
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<note>
|
|
<para>
|
|
Esta función no funciona bien con string binarios. Para hacer un diff de string binario
|
|
utilice <function>xdiff_string_bdiff</function>/<function>xdiff_string_rabdiff</function>.
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>xdiff_string_patch</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
|
|
-->
|