Source of: /manual/en/function.ftp-ssl-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-ssl-connect.php',
1 => 'ftp_ssl_connect',
),
'up' =>
array (
0 => 'ref.ftp.php',
1 => 'FTP Functions',
),
'prev' =>
array (
0 => 'function.ftp-size.php',
1 => 'ftp_size',
),
'next' =>
array (
0 => 'function.ftp-systype.php',
1 => 'ftp_systype',
),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);
manual_header();
?>
<div id="function.ftp-ssl-connect" class="refentry">
<div class="refnamediv">
<h1 class="refname">ftp_ssl_connect</h1>
<p class="verinfo">(PHP 4 >= 4.3.0, PHP 5)</p><p class="refpurpose"><span class="refname">ftp_ssl_connect</span> — <span class="dc-title">Opens an Secure SSL-FTP connection</span></p>
</div>
<a name="function.ftp-ssl-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_ssl_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_ssl_connect()</b> opens a SSL-FTP connection to the
specified <i><tt class="parameter">host</tt></i>
.
</p>
<blockquote><p><b class="note">Note</b>:
<b>Why this function may not exist</b><br />
<b>ftp_ssl_connect()</b> is only available if both
the ftp module and the <a href="ref.openssl.php" class="link">OpenSSL</a>
support is built statically into php, this means that on Windows this
function will be undefined in the official PHP builds. To make this
function available on Windows you must compile your own PHP binaries.
<br />
</p></blockquote>
<blockquote><p><b class="note">Note</b>:
<b>ftp_ssl_connect()</b> is not intended for use with sFTP.
To use sFTP with PHP, please see <a href="function.ssh2-sftp.php" class="function">ssh2_sftp()</a>.
<br />
</p></blockquote>
</div>
<a name="function.ftp-ssl-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't have any trailing
slashes and shouldn'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-ssl-connect.returnvalues"></a><div class="refsect1 returnvalues">
<h3 class="title">Return Values</h3>
<p class="para">
Returns a SSL-FTP stream on success or <b><tt class="constant">FALSE</tt></b> on error.
</p>
</div>
<a name="function.ftp-ssl-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">5.2.2</td>
<td align="left">
The function was changed to return <b><tt class="constant">FALSE</tt></b> when it can't use an SSL
connection, instead of fallbacking to a non-SSL one as previously.
</td>
</tr>
</tbody>
</table>
<p>
</p>
</div>
<a name="function.ftp-ssl-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_ssl_connect()</b> example</b></p>
<div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /><br /></span><span style="color: #FF8000">// set up basic ssl connection<br /></span><span style="color: #0000BB">$conn_id </span><span style="color: #007700">= </span><span style="color: #0000BB">ftp_ssl_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">$ftp_server</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// login with username and password<br /></span><span style="color: #0000BB">$login_result </span><span style="color: #007700">= </span><span style="color: #0000BB">ftp_login</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn_id</span><span style="color: #007700">, </span><span style="color: #0000BB">$ftp_user_name</span><span style="color: #007700">, </span><span style="color: #0000BB">$ftp_user_pass</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #0000BB">ftp_pwd</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn_id</span><span style="color: #007700">); </span><span style="color: #FF8000">// /<br /><br />// close the ssl connection<br /></span><span style="color: #0000BB">ftp_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn_id</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span>
</span>
</code></div>
</div>
</div><p>
</p>
</div>
<a name="function.ftp-ssl-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-connect.php" class="function" rel="rdfs-seeAlso">ftp_connect()</a> - Opens an FTP connection</li>
</ul><p>
</p>
</div>
</div><?php manual_footer(); ?>