<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.ftp.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.ftp-nb-get.php',
    1 => 'ftp_nb_get',
    2 => 'Retrieves a file from the FTP server and writes it to a local file (non-blocking)',
  ),
  'up' => 
  array (
    0 => 'ref.ftp.php',
    1 => 'Функції FTP',
  ),
  'prev' => 
  array (
    0 => 'function.ftp-nb-fput.php',
    1 => 'ftp_nb_fput',
  ),
  'next' => 
  array (
    0 => 'function.ftp-nb-put.php',
    1 => 'ftp_nb_put',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/ftp/functions/ftp-nb-get.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.ftp-nb-get" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ftp_nb_get</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">ftp_nb_get</span> &mdash; <span class="dc-title">Retrieves a file from the FTP server and writes it to a local file (non-blocking)</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.ftp-nb-get-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>ftp_nb_get</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="class.ftp-connection.php" class="type FTP\Connection">FTP\Connection</a></span> <code class="parameter">$ftp</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">$local_filename</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">$remote_filename</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">$mode</code><span class="initializer"> = <strong><code><a href="ftp.constants.php#constant.ftp-binary">FTP_BINARY</a></code></strong></span></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">$offset</code><span class="initializer"> = 0</span></span><br>): <span class="type"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>ftp_nb_get()</strong></span> retrieves a remote file from the FTP server,
   and saves it into a local file. 
  </p>
  <p class="para">
   The difference between this function and <span class="function"><a href="function.ftp-get.php" class="function">ftp_get()</a></span> is that
   this function retrieves the file asynchronously, so your program can perform 
   other operations while the file is being downloaded.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.ftp-nb-get-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">ftp</code></dt>
     <dd>
       <p class="para">Примірник
<span class="classname"><a href="class.ftp-connection.php" class="classname">FTP\Connection</a></span>.</p>
     </dd>
    
    
     <dt><code class="parameter">local_filename</code></dt>
     <dd>
      <p class="para">
       The local file path (will be overwritten if the file already exists).
      </p>
     </dd>
    
    
     <dt><code class="parameter">remote_filename</code></dt>
     <dd>
      <p class="para">
       The remote file path.
      </p>
     </dd>
    
    
     <dt><code class="parameter">mode</code></dt>
     <dd>
      <p class="para">
       The transfer mode. Must be either <strong><code><a href="ftp.constants.php#constant.ftp-ascii">FTP_ASCII</a></code></strong> or
       <strong><code><a href="ftp.constants.php#constant.ftp-binary">FTP_BINARY</a></code></strong>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">offset</code></dt>
     <dd>
      <p class="para">The position in the remote file to start downloading from.</p>
     </dd>
    
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.ftp-nb-get-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Returns <strong><code><a href="ftp.constants.php#constant.ftp-failed">FTP_FAILED</a></code></strong> or <strong><code><a href="ftp.constants.php#constant.ftp-finished">FTP_FINISHED</a></code></strong>
   or <strong><code><a href="ftp.constants.php#constant.ftp-moredata">FTP_MOREDATA</a></code></strong>, or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> on failure to open the local file.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.ftp-nb-get-changelog">
  <h3 class="title">Журнал змін</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Версія</th>
      <th>Опис</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.1.0</td>
 <td>
  Тепер параметр <code class="parameter">ftp</code> має бути примірником
  <span class="classname"><a href="class.ftp-connection.php" class="classname">FTP\Connection</a></span>. Раніше очікувався <a href="language.types.resource.php" class="link">resource</a>.
 </td>
</tr>

     <tr>
      <td>7.3.0</td>
      <td>
       The <code class="parameter">mode</code> parameter is now optional. Formerly it
       has been mandatory.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.ftp-nb-get-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 <span class="function"><strong>ftp_nb_get()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">// Initiate the download<br /></span><span style="color: #0000BB">$ret </span><span style="color: #007700">= </span><span style="color: #0000BB">ftp_nb_get</span><span style="color: #007700">(</span><span style="color: #0000BB">$ftp</span><span style="color: #007700">, </span><span style="color: #DD0000">"test"</span><span style="color: #007700">, </span><span style="color: #DD0000">"README"</span><span style="color: #007700">, </span><span style="color: #0000BB">FTP_BINARY</span><span style="color: #007700">);<br />while (</span><span style="color: #0000BB">$ret </span><span style="color: #007700">== </span><span style="color: #0000BB">FTP_MOREDATA</span><span style="color: #007700">) {<br />   <br />   </span><span style="color: #FF8000">// Do whatever you want<br />   </span><span style="color: #007700">echo </span><span style="color: #DD0000">"."</span><span style="color: #007700">;<br /><br />   </span><span style="color: #FF8000">// Continue downloading...<br />   </span><span style="color: #0000BB">$ret </span><span style="color: #007700">= </span><span style="color: #0000BB">ftp_nb_continue</span><span style="color: #007700">(</span><span style="color: #0000BB">$ftp</span><span style="color: #007700">);<br />}<br />if (</span><span style="color: #0000BB">$ret </span><span style="color: #007700">!= </span><span style="color: #0000BB">FTP_FINISHED</span><span style="color: #007700">) {<br />   echo </span><span style="color: #DD0000">"There was an error downloading the file..."</span><span style="color: #007700">;<br />   exit(</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
   <div class="example" id="example-2">
    <p><strong>Приклад #2 Resuming a download with <span class="function"><strong>ftp_nb_get()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">// Initiate <br /></span><span style="color: #0000BB">$ret </span><span style="color: #007700">= </span><span style="color: #0000BB">ftp_nb_get</span><span style="color: #007700">(</span><span style="color: #0000BB">$ftp</span><span style="color: #007700">, </span><span style="color: #DD0000">"test"</span><span style="color: #007700">, </span><span style="color: #DD0000">"README"</span><span style="color: #007700">, </span><span style="color: #0000BB">FTP_BINARY</span><span style="color: #007700">, <br />                      </span><span style="color: #0000BB">filesize</span><span style="color: #007700">(</span><span style="color: #DD0000">"test"</span><span style="color: #007700">));<br /></span><span style="color: #FF8000">// OR: $ret = ftp_nb_get($ftp, "test", "README", <br />//                           FTP_BINARY, FTP_AUTORESUME);<br /></span><span style="color: #007700">while (</span><span style="color: #0000BB">$ret </span><span style="color: #007700">== </span><span style="color: #0000BB">FTP_MOREDATA</span><span style="color: #007700">) {<br />   <br />   </span><span style="color: #FF8000">// Do whatever you want<br />   </span><span style="color: #007700">echo </span><span style="color: #DD0000">"."</span><span style="color: #007700">;<br /><br />   </span><span style="color: #FF8000">// Continue downloading...<br />   </span><span style="color: #0000BB">$ret </span><span style="color: #007700">= </span><span style="color: #0000BB">ftp_nb_continue</span><span style="color: #007700">(</span><span style="color: #0000BB">$ftp</span><span style="color: #007700">);<br />}<br />if (</span><span style="color: #0000BB">$ret </span><span style="color: #007700">!= </span><span style="color: #0000BB">FTP_FINISHED</span><span style="color: #007700">) {<br />   echo </span><span style="color: #DD0000">"There was an error downloading the file..."</span><span style="color: #007700">;<br />   exit(</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
   <div class="example" id="example-3">
    <p><strong>Приклад #3 
     Resuming a download at position 100 to a new
     file with <span class="function"><strong>ftp_nb_get()</strong></span>
    </strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">// Disable Autoseek<br /></span><span style="color: #0000BB">ftp_set_option</span><span style="color: #007700">(</span><span style="color: #0000BB">$ftp</span><span style="color: #007700">, </span><span style="color: #0000BB">FTP_AUTOSEEK</span><span style="color: #007700">, </span><span style="color: #0000BB">false</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Initiate<br /></span><span style="color: #0000BB">$ret </span><span style="color: #007700">= </span><span style="color: #0000BB">ftp_nb_get</span><span style="color: #007700">(</span><span style="color: #0000BB">$ftp</span><span style="color: #007700">, </span><span style="color: #DD0000">"newfile"</span><span style="color: #007700">, </span><span style="color: #DD0000">"README"</span><span style="color: #007700">, </span><span style="color: #0000BB">FTP_BINARY</span><span style="color: #007700">, </span><span style="color: #0000BB">100</span><span style="color: #007700">);<br />while (</span><span style="color: #0000BB">$ret </span><span style="color: #007700">== </span><span style="color: #0000BB">FTP_MOREDATA</span><span style="color: #007700">) {<br /><br />   </span><span style="color: #FF8000">/* ... */<br />   <br />   // Continue downloading...<br />   </span><span style="color: #0000BB">$ret </span><span style="color: #007700">= </span><span style="color: #0000BB">ftp_nb_continue</span><span style="color: #007700">(</span><span style="color: #0000BB">$ftp</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
  <p class="para">
   In the example above, <var class="filename">newfile</var> is 100 bytes smaller
   than <var class="filename">README</var> on the FTP server because we started
   reading at offset 100. If we didn&#039;t disable 
   <strong><code><a href="ftp.constants.php#constant.ftp-autoseek">FTP_AUTOSEEK</a></code></strong>, the first 100 bytes of
   <var class="filename">newfile</var> would be <code class="literal">&#039;\0&#039;</code>.
  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.ftp-nb-get-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.ftp-nb-fget.php" class="function" rel="rdfs-seeAlso">ftp_nb_fget()</a> - Retrieves a file from the FTP server and writes it to an open file (non-blocking)</span></li>
    <li><span class="function"><a href="function.ftp-nb-continue.php" class="function" rel="rdfs-seeAlso">ftp_nb_continue()</a> - Continues retrieving/sending a file (non-blocking)</span></li>
    <li><span class="function"><a href="function.ftp-fget.php" class="function" rel="rdfs-seeAlso">ftp_fget()</a> - Downloads a file from the FTP server and saves to an open file</span></li>
    <li><span class="function"><a href="function.ftp-get.php" class="function" rel="rdfs-seeAlso">ftp_get()</a> - Downloads a file from the FTP server</span></li>
   </ul>
  </p>
 </div>

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