mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 05:26:57 +08:00
162 lines
7.5 KiB
HTML
162 lines
7.5 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||
<html>
|
||
<head>
|
||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||
<title>打开 SSL-FTP 连接</title>
|
||
</head>
|
||
<body class="docs"><div id="layout">
|
||
<div id="layout-content"><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, PHP 7)</p><p class="refpurpose"><span class="refname">ftp_ssl_connect</span> — <span class="dc-title">打开 SSL-FTP 连接</span></p>
|
||
|
||
</div>
|
||
<div class="refsect1 description" id="refsect1-function.ftp-ssl-connect-description">
|
||
<h3 class="title">说明</h3>
|
||
<div class="methodsynopsis dc-description">
|
||
<span class="methodname"><strong>ftp_ssl_connect</strong></span>
|
||
( <span class="methodparam"><span class="type">string</span> <code class="parameter">$host</code></span>
|
||
[, <span class="methodparam"><span class="type">int</span> <code class="parameter">$port</code><span class="initializer"> = 21</span></span>
|
||
[, <span class="methodparam"><span class="type">int</span> <code class="parameter">$timeout</code><span class="initializer"> = 90</span></span>
|
||
]] ) : <span class="type">resource</span></div>
|
||
|
||
<p class="para rdfs-comment">
|
||
<span class="function"><strong>ftp_ssl_connect()</strong></span> <em class="emphasis">显式</em>的打开一个到
|
||
<code class="parameter">host</code> 的安全 FTP 连接(SSL-FTP)。
|
||
即使服务器未配置 SSL-FTP,或者服务器的证书无效,<span class="function"><strong>ftp_ssl_connect()</strong></span>
|
||
函数也会成功的建立到服务器的连接。直到调用 <span class="function"><a href="ftp_login.html" class="function">ftp_login()</a></span> 函数的时候,
|
||
客户端才会发送对应的 AUTH FTP 命令,此时,如果服务器未配置 SSL-FTP 或者整数无效,
|
||
<span class="function"><a href="ftp_login.html" class="function">ftp_login()</a></span> 函数会失败。
|
||
</p>
|
||
<blockquote class="note"><p><strong class="note">Note</strong>:
|
||
<strong>为何本函数有可能不存在?</strong><br />
|
||
<p class="para">
|
||
只有 PHP 构建时同时包含了 ftp 模块
|
||
和 <a href="ref.openssl.html" class="link">OpenSSL</a> 模块时,
|
||
<span class="function"><strong>ftp_ssl_connect()</strong></span> 函数才可用。
|
||
也就是说,在 Windows 平台上,官方发布的 PHP 构建中本函数不可用。
|
||
如果需要在 Windows 平台使用本函数,需要自行编译 PHP。
|
||
</p>
|
||
</p></blockquote>
|
||
<blockquote class="note"><p><strong class="note">Note</strong>:
|
||
<p class="para">
|
||
<span class="function"><strong>ftp_ssl_connect()</strong></span> 不是用来连接 sFTP 服务的。
|
||
要在 PHP 中使用 sFTP,请参见 <span class="function"><a href="ssh2_sftp.html" class="function">ssh2_sftp()</a></span>。
|
||
</p>
|
||
</p></blockquote>
|
||
</div>
|
||
|
||
<div class="refsect1 parameters" id="refsect1-function.ftp-ssl-connect-parameters">
|
||
<h3 class="title">参数</h3>
|
||
<p class="para">
|
||
<dl>
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">host</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
FTP 服务器地址。
|
||
此参数末尾不可以有斜线,开头也不可以有 <em>ftp://</em>。
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">port</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
要连接的端口。如果省略此参数或设置为 0,将使用 FTP 默认端口 21。
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">timeout</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
此参数设置所有后续网络操作的超时时长。
|
||
如果省略,默认值为 90 秒。
|
||
可以使用 <span class="function"><a href="ftp_set_option.html" class="function">ftp_set_option()</a></span> 和
|
||
<span class="function"><a href="ftp_get_option.html" class="function">ftp_get_option()</a></span> 函数随时读取或设置超时时长。
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
</dl>
|
||
|
||
</p>
|
||
</div>
|
||
|
||
<div class="refsect1 returnvalues" id="refsect1-function.ftp-ssl-connect-returnvalues">
|
||
<h3 class="title">返回值</h3>
|
||
<p class="para">
|
||
操作成功返回 SSL-FTP 流,操作失败返回 <strong><code>FALSE</code></strong> 。
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 changelog" id="refsect1-function.ftp-ssl-connect-changelog">
|
||
<h3 class="title">更新日志</h3>
|
||
<p class="para">
|
||
<table class="doctable informaltable">
|
||
|
||
<thead>
|
||
<tr>
|
||
<th>版本</th>
|
||
<th>说明</th>
|
||
</tr>
|
||
|
||
</thead>
|
||
|
||
<tbody class="tbody">
|
||
<tr>
|
||
<td>5.2.2</td>
|
||
<td>
|
||
以前版本中,如果无法使用 SSL 连接,将会返回一个非 SSL 的连接,
|
||
在 5.2.2 版本中修改为返回 <strong><code>FALSE</code></strong>
|
||
</td>
|
||
</tr>
|
||
|
||
</tbody>
|
||
|
||
</table>
|
||
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 examples" id="refsect1-function.ftp-ssl-connect-examples">
|
||
<h3 class="title">范例</h3>
|
||
<p class="para">
|
||
<div class="example" id="example-5336">
|
||
<p><strong>Example #1 <span class="function"><strong>ftp_ssl_connect()</strong></span> 函数例程</strong></p>
|
||
<div class="example-contents">
|
||
<div class="phpcode"><pre><span style="color: #000000">
|
||
<span style="color: #0000BB"><?php<br /><br /></span><span style="color: #FF8000">// 建立基础 SSL 连接<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">// 使用用户名和密码登录<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 />if (!</span><span style="color: #0000BB">$login_result</span><span style="color: #007700">) {<br /> </span><span style="color: #FF8000">// 在这种情况下,PHP 会发生 E_WARNING 级别的告警消息<br /> </span><span style="color: #007700">die(</span><span style="color: #DD0000">"can't login"</span><span style="color: #007700">);<br />}<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 />// 关闭 ssl 连接<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>
|
||
</pre></div>
|
||
</div>
|
||
|
||
</div>
|
||
</p>
|
||
</div>
|
||
|
||
<div class="refsect1 seealso" id="refsect1-function.ftp-ssl-connect-seealso">
|
||
<h3 class="title">参见</h3>
|
||
<p class="para">
|
||
<ul class="simplelist">
|
||
<li class="member"><span class="function"><a href="ftp_connect.html" class="function" rel="rdfs-seeAlso">ftp_connect()</a> - 建立一个新的 FTP 连接</span></li>
|
||
</ul>
|
||
</p>
|
||
</div>
|
||
|
||
</div></div></div></body></html> |