<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.svn.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.svn-diff.php',
    1 => 'svn_diff',
    2 => 'Recursively diffs two paths',
  ),
  'up' => 
  array (
    0 => 'ref.svn.php',
    1 => 'SVN Функції',
  ),
  'prev' => 
  array (
    0 => 'function.svn-delete.php',
    1 => 'svn_delete',
  ),
  'next' => 
  array (
    0 => 'function.svn-export.php',
    1 => 'svn_export',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/svn/functions/svn-diff.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.svn-diff" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">svn_diff</h1>
  <p class="verinfo">(PECL svn &gt;= 0.1.0)</p><p class="refpurpose"><span class="refname">svn_diff</span> &mdash; <span class="dc-title">Recursively diffs two paths</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.svn-diff-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>svn_diff</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$path1</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$rev1</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$path2</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$rev2</code></span><br>): <span class="type"><a href="language.types.array.php" class="type array">array</a></span></div>

  <p class="para rdfs-comment">
   Recursively diffs two paths, <code class="parameter">path1</code> and
   <code class="parameter">path2</code>.
  </p>
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <p class="para">
    This is not a general-purpose diff utility. Only local files
    that are versioned may be diffed: other files will fail.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.svn-diff-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">path1</code></dt>
     <dd>
      <p class="para">
       First path to diff. This can be a URL to a file/directory in an SVN
       repository or a local file/directory path.
      </p>
      <blockquote class="note"><p><strong class="note">Зауваження</strong>: <span class="simpara">Відносні шляхи
розкриваються так, ніби поточною текою є та, що містить виконуваний файл PHP.
Щоб використовувати теку, в якій виконується скрипт, застосовується функція
<span class="function"><a href="function.realpath.php" class="function">realpath()</a></span> або dirname(__FILE__).</span></p></blockquote>
      <div class="warning"><strong class="warning">Увага</strong>
       <p class="simpara">
        If a local file path has only backslashes and no forward slashes,
        this extension will fail to find the path. Always
        replace all backslashes with forward slashes when using this
        function.
       </p>
      </div>
     </dd>
    
    
     <dt><code class="parameter">rev1</code></dt>
     <dd>
      <p class="para">
       First path&#039;s revision number. Use <strong><code><a href="svn.constants.php#constant.svn-revision-head">SVN_REVISION_HEAD</a></code></strong>
       to specify the most recent revision.
      </p>
     </dd>
    
    
     <dt><code class="parameter">path2</code></dt>
     <dd>
      <p class="para">
       Second path to diff. See <code class="parameter">path1</code> for description.
      </p>
     </dd>
    
    
     <dt><code class="parameter">rev2</code></dt>
     <dd>
      <p class="para">
       Second path&#039;s revision number. See <code class="parameter">rev1</code>
       for description.
      </p>
     </dd>
    
   </dl>
  </p>

 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.svn-diff-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Returns an array-list consisting of two streams: the first is the diff output
   and the second contains error stream output. The streams can be
   read using <span class="function"><a href="function.fread.php" class="function">fread()</a></span>. Returns <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> or <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> on
   error.
  </p>
  <p class="para">
   The diff output will, by default, be in the form of Subversion&#039;s
   custom unified diff format, but an
   <a href="http://svnbook.red-bean.com/en/1.2/svn.advanced.externaldifftools.html" class="link external">&raquo;&nbsp;external
   diff engine</a> may be
   used depending on Subversion&#039;s configuration.
  </p>
 </div>


 

 

 <div class="refsect1 examples" id="refsect1-function.svn-diff-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 Basic example</strong></p>
    <div class="example-contents"><p>
     This example demonstrates the basic usage of this function, and
     the retrieval of contents from the stream:
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">list(</span><span style="color: #0000BB">$diff</span><span style="color: #007700">, </span><span style="color: #0000BB">$errors</span><span style="color: #007700">) = </span><span style="color: #0000BB">svn_diff</span><span style="color: #007700">(<br />    </span><span style="color: #DD0000">'http://www.example.com/svnroot/trunk/foo'</span><span style="color: #007700">, </span><span style="color: #0000BB">SVN_REVISION_HEAD</span><span style="color: #007700">,<br />    </span><span style="color: #DD0000">'http://www.example.com/svnroot/branches/dev/foo'</span><span style="color: #007700">, </span><span style="color: #0000BB">SVN_REVISION_HEAD<br /></span><span style="color: #007700">);<br />if (!</span><span style="color: #0000BB">$diff</span><span style="color: #007700">) exit;<br /></span><span style="color: #0000BB">$contents </span><span style="color: #007700">= </span><span style="color: #DD0000">''</span><span style="color: #007700">;<br />while (!</span><span style="color: #0000BB">feof</span><span style="color: #007700">(</span><span style="color: #0000BB">$diff</span><span style="color: #007700">)) {<br />  </span><span style="color: #0000BB">$contents </span><span style="color: #007700">.= </span><span style="color: #0000BB">fread</span><span style="color: #007700">(</span><span style="color: #0000BB">$diff</span><span style="color: #007700">, </span><span style="color: #0000BB">8192</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$diff</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$errors</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$contents</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Поданий вище приклад
виведе:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Index: http://www.example.com/svnroot/trunk/foo
===================================================================
--- http://www.example.com/svnroot/trunk/foo        (.../foo) (revision 23)
+++ http://www.example.com/svnroot/branches/dev/foo (.../foo) (revision 27)
 // further diff output</pre>
</div>
    </div>
   </div>
  </p>
  <p class="para">
   <div class="example" id="example-2">
    <p><strong>Приклад #2 Diffing two revisions of a repository path</strong></p>
    <div class="example-contents"><p>
     This example implements a wrapper function that allows a user
     to easily diff two revisions of the same item using an external
     repository path (the default syntax is somewhat verbose):
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">svn_diff_same_item</span><span style="color: #007700">(</span><span style="color: #0000BB">$path</span><span style="color: #007700">, </span><span style="color: #0000BB">$rev1</span><span style="color: #007700">, </span><span style="color: #0000BB">$rev2</span><span style="color: #007700">) {<br />    return </span><span style="color: #0000BB">svn_diff</span><span style="color: #007700">(</span><span style="color: #0000BB">$path</span><span style="color: #007700">, </span><span style="color: #0000BB">$rev1</span><span style="color: #007700">, </span><span style="color: #0000BB">$path</span><span style="color: #007700">, </span><span style="color: #0000BB">$rev2</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
  <p class="para">
   <div class="example" id="example-3">
    <p><strong>Приклад #3 Portably diffing two local files</strong></p>
    <div class="example-contents"><p>
     This example implements a wrapper function that portably
     diffs two local files, compensating for the <span class="function"><a href="function.realpath.php" class="function">realpath()</a></span>
     fix and the backslashes bug:
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">svn_diff_local</span><span style="color: #007700">(</span><span style="color: #0000BB">$path1</span><span style="color: #007700">, </span><span style="color: #0000BB">$rev1</span><span style="color: #007700">, </span><span style="color: #0000BB">$path2</span><span style="color: #007700">, </span><span style="color: #0000BB">$rev2</span><span style="color: #007700">) {<br />    </span><span style="color: #0000BB">$path1 </span><span style="color: #007700">= </span><span style="color: #0000BB">str_replace</span><span style="color: #007700">(</span><span style="color: #DD0000">'\\'</span><span style="color: #007700">, </span><span style="color: #DD0000">'/'</span><span style="color: #007700">, </span><span style="color: #0000BB">realpath</span><span style="color: #007700">(</span><span style="color: #0000BB">$path1</span><span style="color: #007700">));<br />    </span><span style="color: #0000BB">$path2 </span><span style="color: #007700">= </span><span style="color: #0000BB">str_replace</span><span style="color: #007700">(</span><span style="color: #DD0000">'\\'</span><span style="color: #007700">, </span><span style="color: #DD0000">'/'</span><span style="color: #007700">, </span><span style="color: #0000BB">realpath</span><span style="color: #007700">(</span><span style="color: #0000BB">$path2</span><span style="color: #007700">));<br />    return </span><span style="color: #0000BB">svn_diff</span><span style="color: #007700">(</span><span style="color: #0000BB">$path1</span><span style="color: #007700">, </span><span style="color: #0000BB">$rev1</span><span style="color: #007700">, </span><span style="color: #0000BB">$path2</span><span style="color: #007700">, </span><span style="color: #0000BB">$rev2</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

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


 <div class="refsect1 notes" id="refsect1-function.svn-diff-notes">
  <h3 class="title">Примітки</h3>
  <div class="warning"><strong class="warning">Увага</strong><p class="simpara">Ця функція —
<em>ЕКСПЕРИМЕНТАЛЬНА</em>. Її поведінка, назва та документація
можуть бути змінені без попередження в майбутніх випусках PHP. Використання цієї
функції є ризикованим для розробника.</p></div>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-function.svn-diff-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><a href="http://svnbook.red-bean.com/en/1.2/svn.ref.svn.c.diff.html" class="link external">&raquo;&nbsp;SVN documentation on svn diff</a></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>