downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/function.xdiff-file-diff.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/ref.xdiff.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'function.xdiff-file-diff.php',
   
1 => 'xdiff_file_diff',
  ),
 
'up' =>
  array (
   
0 => 'ref.xdiff.php',
   
1 => 'xdiff Functions',
  ),
 
'prev' =>
  array (
   
0 => 'function.xdiff-file-diff-binary.php',
   
1 => 'xdiff_file_diff_binary',
  ),
 
'next' =>
  array (
   
0 => 'function.xdiff-file-merge3.php',
   
1 => 'xdiff_file_merge3',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="function.xdiff-file-diff" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">xdiff_file_diff</h1>
  <p class="verinfo">(PECL xdiff &gt;= 0.2.0)</p><p class="refpurpose"><span class="refname">xdiff_file_diff</span> &mdash; <span class="dc-title">Make unified diff of two files</span></p>

 </div>
 
 <a name="function.xdiff-file-diff.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><b>xdiff_file_diff</b></span>
    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$old_file</tt></span>
   , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$new_file</tt></span>
   , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$dest</tt></span>
   [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$context</tt><span class="initializer"> = 3</span></span>
   [, <span class="methodparam"><span class="type">bool</span> <tt class="parameter">$minimal</tt><span class="initializer"> = false</span></span>
  ]] )</div>

  <p class="para rdfs-comment">
   Makes an unified diff containing differences between <i><tt class="parameter">old_file</tt></i>
 and
   <i><tt class="parameter">new_file</tt></i>
 and stores it in <i><tt class="parameter">dest</tt></i>
 file. The
   resulting file is human-readable. An optional <i><tt class="parameter">context</tt></i>
 parameter
   specifies how many lines of context should be added around each change (with default value of 3).
   Setting <i><tt class="parameter">minimal</tt></i>
 parameter to true will result in outputting the shortest
   patch file possible (can take a long time).
  </p>
 </div>


 <a name="function.xdiff-file-diff.parameters"></a><div class="refsect1 parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   </p><dl>

    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">old_file</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       Path to the first file. This file acts as &quot;old&quot; file.
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">new_file</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       Path to the second file. This file acts as &quot;new&quot; file.
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">dest</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       Path of the resulting patch file.
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">context</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       Indicates how many lines of context you want to include in diff
       result. Default is 3.
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">minimal</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       Set this parameter to <b><tt class="constant">TRUE</tt></b> if you want to minimalize size of the result
       (can take a long time).
      </p>
     </dd>

   
   </dl>
<p>
  </p>
 </div>


 <a name="function.xdiff-file-diff.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns <b><tt class="constant">TRUE</tt></b> on success or <b><tt class="constant">FALSE</tt></b> on failure.
  </p>
 </div>


 <a name="function.xdiff-file-diff.examples"></a><div class="refsect1 examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   </p><div class="example">
    <p><b>Example #1 <b>xdiff_file_diff()</b> example</b></p>
    <div class="example-contents para"><p>
     The following code makes unified diff of two php files with context length of 2.
    </p></div>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$old_version&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'my_script.php'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$new_version&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'my_new_script.php'</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">xdiff_file_diff</span><span style="color: #007700">(</span><span style="color: #0000BB">$old_version</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$new_version</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'my_script.diff'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div><p>
  </p>
 </div>


 <a name="function.xdiff-file-diff.notes"></a><div class="refsect1 notes">
  <h3 class="title">Notes</h3>
  <blockquote><p><b class="note">Note</b>:
  
    This function doesn&#039;t work well with binary files. To make diff of binary
    files use <a href="function.xdiff-file-bdiff.php" class="function">xdiff_file_bdiff()</a>/<a href="function.xdiff-file-rabdiff.php" class="function">xdiff_file_rabdiff()</a> function.
   <br />
  </p></blockquote>
 </div>


 <a name="function.xdiff-file-diff.seealso"></a><div class="refsect1 seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   </p><ul class="simplelist">
    <li class="member"><a href="function.xdiff-file-patch.php" class="function" rel="rdfs-seeAlso">xdiff_file_patch()</a> - Patch a file with an unified diff</li>
   </ul><p>
  </p>
 </div>

</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites