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.ftp-connect.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = 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 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'function.ftp-connect.php',
   
1 => 'ftp_connect',
  ),
 
'up' =>
  array (
   
0 => 'ref.ftp.php',
   
1 => 'FTP Functions',
  ),
 
'prev' =>
  array (
   
0 => 'function.ftp-close.php',
   
1 => 'ftp_close',
  ),
 
'next' =>
  array (
   
0 => 'function.ftp-delete.php',
   
1 => 'ftp_delete',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="function.ftp-connect" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ftp_connect</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">ftp_connect</span> &mdash; <span class="dc-title">Opens an FTP connection</span></p>

 </div>
 <a name="function.ftp-connect.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">resource</span> <span class="methodname"><b>ftp_connect</b></span>
    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$host</tt></span>
   [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$port</tt><span class="initializer"> = 21</span></span>
   [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$timeout</tt><span class="initializer"> = 90</span></span>
  ]] )</div>

  <p class="para rdfs-comment">
   <b>ftp_connect()</b> opens an FTP connection to the
   specified <i><tt class="parameter">host</tt></i>

  </p>
 </div>

 <a name="function.ftp-connect.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">host</tt></i>
</span>

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

      <p class="para">
       The FTP server address. This parameter shouldn&#039;t have any trailing
       slashes and shouldn&#039;t be prefixed with <i>ftp://</i>.
      </p>
     </dd>

   
    <dt class="varlistentry">

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

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

      <p class="para">
       This parameter specifies an alternate port to connect to. If it is
       omitted or set to zero, then the default FTP port, 21, will be used.
      </p>
     </dd>

   
    <dt class="varlistentry">

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

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

      <p class="para">
       This parameter specifies the timeout for all subsequent network operations.
       If omitted, the default value is 90 seconds. The timeout can be changed and
       queried at any time with <a href="function.ftp-set-option.php" class="function">ftp_set_option()</a> and
       <a href="function.ftp-get-option.php" class="function">ftp_get_option()</a>.
      </p>
     </dd>

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

 <a name="function.ftp-connect.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns a FTP stream on success or <b><tt class="constant">FALSE</tt></b> on error.
  </p>
 </div>

 <a name="function.ftp-connect.examples"></a><div class="refsect1 examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   </p><div class="example">
    <p><b>Example #1 <b>ftp_connect()</b> example</b></p>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$ftp_server&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"ftp.example.com"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;set&nbsp;up&nbsp;a&nbsp;connection&nbsp;or&nbsp;die<br /></span><span style="color: #0000BB">$conn_id&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ftp_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">$ftp_server</span><span style="color: #007700">)&nbsp;or&nbsp;die(</span><span style="color: #DD0000">"Couldn't&nbsp;connect&nbsp;to&nbsp;</span><span style="color: #0000BB">$ftp_server</span><span style="color: #DD0000">"</span><span style="color: #007700">);&nbsp;<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div> 
    </div>

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

 <a name="function.ftp-connect.changelog"></a><div class="refsect1 changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   </p><table class="doctable informaltable">
   
     <thead valign="middle">
      <tr valign="middle">
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody valign="middle" class="tbody">
      <tr valign="middle">
       <td align="left">4.2.0</td>
       <td align="left">
        <i><tt class="parameter">timeout</tt></i>
 was added.
       </td>
      </tr>

     </tbody>
   
   </table>
<p>
  </p>
 </div>

 <a name="function.ftp-connect.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.ftp-close.php" class="function" rel="rdfs-seeAlso">ftp_close()</a> - Closes an FTP connection</li>
    <li class="member"><a href="function.ftp-ssl-connect.php" class="function" rel="rdfs-seeAlso">ftp_ssl_connect()</a> - Opens an Secure SSL-FTP connection</li>
   </ul><p>
  </p>
 </div>

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