-
Notifications
You must be signed in to change notification settings - Fork 105
/
Copy pathftp-ssl-connect.xml
161 lines (154 loc) · 4.91 KB
/
ftp-ssl-connect.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 11a4d4964802dbc147f369b8a16df692c391cd2f Maintainer: yuanyuqiang Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<refentry xml:id="function.ftp-ssl-connect" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>ftp_ssl_connect</refname>
<refpurpose>打开安全 SSL-FTP 连接</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type class="union"><type>FTP\Connection</type><type>false</type></type><methodname>ftp_ssl_connect</methodname>
<methodparam><type>string</type><parameter>hostname</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>port</parameter><initializer>21</initializer></methodparam>
<methodparam choice="opt"><type>int</type><parameter>timeout</parameter><initializer>90</initializer></methodparam>
</methodsynopsis>
<para>
<function>ftp_ssl_connect</function> 打开到指定 <parameter>hostname</parameter> 的<emphasis>明确</emphasis>
SSL-FTP 连接。即使服务器没有为 SSL-FTP 配置,<function>ftp_ssl_connect</function>
也会成功。只有调用 <function>ftp_login</function> 时,客户端才会发送对应的 <literal>AUTH FTP</literal>
命令,因此 <function>ftp_login</function> 会失败。<function>ftp_ssl_connect</function> 建立的连接<emphasis>不会</emphasis>进行对等证书验证。
</para>
<note>
<title>为何本函数有可能不存在?</title>
<para>
在 PHP 7.0 之前,只有 ftp 模块和 <link linkend="ref.openssl">OpenSSL</link> 模块都静态编译到 PHP
时,<function>ftp_ssl_connect</function> 才可用;也就是说,在 Windows 平台上,此函数在官方 PHP
编译中未定义。如果需要在 Windows 平台使用本函数,需要自行编译 PHP 二进制文件。
</para>
</note>
<note>
<para>
<function>ftp_ssl_connect</function> 不是用来连接 sFTP 服务的。
要在 PHP 中使用 sFTP,请参见 <function>ssh2_sftp</function>。
</para>
</note>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>hostname</parameter></term>
<listitem>
<para>
FTP 服务器地址。
此参数末尾不可以有斜线,开头也不可以有 <literal>ftp://</literal>。
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>port</parameter></term>
<listitem>
<para>
要连接的端口。如果省略此参数或设置为 0,将使用 FTP 默认端口 21。
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>timeout</parameter></term>
<listitem>
<para>
此参数设置所有后续网络操作的超时时长。
如果省略,默认值为 90 秒。
可以使用 <function>ftp_set_option</function> 和
<function>ftp_get_option</function> 函数随时读取或设置超时时长。
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
成功时返回 <classname>FTP\Connection</classname> 实例,&return.falseforfailure;。
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>8.1.0</entry>
<entry>
现在返回 <classname>FTP\Connection</classname> 实例;之前返回 &resource;。
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>ftp_ssl_connect</function> 函数示例</title>
<programlisting role="php">
<![CDATA[
<?php
// 建立基础 SSL 连接
$ftp = ftp_ssl_connect($ftp_server);
// 使用用户名和密码登录
$login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass);
if (!$login_result) {
// 在这种情况下,PHP 会发生 E_WARNING 级别的告警消息
die("can't login");
}
echo ftp_pwd($ftp); // /
// 关闭 ssl 连接
ftp_close($ftp);
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>ftp_connect</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->