reference/ftp/functions/ftp-ssl-connect.xml
4d1c34c9b7a30cfc3a59641122c707a2812cfed7
...
...
@@ -3,28 +3,33 @@
3
3
<refentry xml:id="function.ftp-ssl-connect" xmlns="http://docbook.org/ns/docbook">
4
4
<refnamediv>
5
5
<refname>ftp_ssl_connect</refname>
6
-
<refpurpose>Opens an Secure SSL-FTP connection</refpurpose>
6
+
<refpurpose>Opens a Secure SSL-FTP connection</refpurpose>
7
7
</refnamediv>
8
8
<refsect1 role="description">
9
9
&reftitle.description;
10
10
<methodsynopsis>
11
-
<type>resource</type><methodname>ftp_ssl_connect</methodname>
12
-
<methodparam><type>string</type><parameter>host</parameter></methodparam>
11
+
<type class="union"><type>FTP\Connection</type><type>false</type></type><methodname>ftp_ssl_connect</methodname>
12
+
<methodparam><type>string</type><parameter>hostname</parameter></methodparam>
13
13
<methodparam choice="opt"><type>int</type><parameter>port</parameter><initializer>21</initializer></methodparam>
14
14
<methodparam choice="opt"><type>int</type><parameter>timeout</parameter><initializer>90</initializer></methodparam>
15
15
</methodsynopsis>
16
16
<para>
17
-
<function>ftp_ssl_connect</function> opens an explicit SSL-FTP connection to the
18
-
specified <parameter>host</parameter>.
17
+
<function>ftp_ssl_connect</function> opens an <emphasis>explicit</emphasis> SSL-FTP connection to the
18
+
specified <parameter>hostname</parameter>. That implies that
19
+
<function>ftp_ssl_connect</function> will succeed even if the server is not
20
+
configured for SSL-FTP, or its certificate is invalid. Only when
21
+
<function>ftp_login</function> is called, the client will send the
22
+
appropriate AUTH FTP command, so <function>ftp_login</function> will fail in
23
+
the mentioned cases.
19
24
</para>
20
25
<note>
21
26
<title>Why this function may not exist</title>
22
27
<para>
23
-
<function>ftp_ssl_connect</function> is only available if both
28
+
Before PHP 7.0.0, <function>ftp_ssl_connect</function> was only available if both
24
29
the ftp module and the <link linkend="ref.openssl">OpenSSL</link>
25
-
support is built statically into php, this means that on Windows this
26
-
function will be undefined in the official PHP builds. To make this
27
-
function available on Windows you must compile your own PHP binaries.
30
+
support have been built statically into php; this means that on Windows this
31
+
function had been undefined in the official PHP builds. To have this
32
+
function available on Windows, it had been necessary to compile own PHP binaries.
28
33
</para>
29
34
</note>
30
35
<note>
...
...
@@ -39,7 +44,7 @@
39
44
<para>
40
45
<variablelist>
41
46
<varlistentry>
42
-
<term><parameter>host</parameter></term>
47
+
<term><parameter>hostname</parameter></term>
43
48
<listitem>
44
49
<para>
45
50
The FTP server address. This parameter shouldn't have any trailing
...
...
@@ -73,33 +78,31 @@
73
78
<refsect1 role="returnvalues">
74
79
&reftitle.returnvalues;
75
80
<para>
76
-
Returns a SSL-FTP stream on success or &false; on error.
81
+
Returns an <classname>FTP\Connection</classname> instance on success,&return.falseforfailure;.
77
82
</para>
78
83
</refsect1>
79
84

80
85
<refsect1 role="changelog">
81
86
&reftitle.changelog;
82
-
<para>
83
-
<informaltable>
84
-
<tgroup cols="2">
85
-
<thead>
86
-
<row>
87
-
<entry>&Version;</entry>
88
-
<entry>&Description;</entry>
89
-
</row>
90
-
</thead>
91
-
<tbody>
92
-
<row>
93
-
<entry>5.2.2</entry>
94
-
<entry>
95
-
The function was changed to return &false; when it can't use an SSL
96
-
connection, instead of fallbacking to a non-SSL one as previously.
97
-
</entry>
98
-
</row>
99
-
</tbody>
100
-
</tgroup>
101
-
</informaltable>
102
-
</para>
87
+
<informaltable>
88
+
<tgroup cols="2">
89
+
<thead>
90
+
<row>
91
+
<entry>&Version;</entry>
92
+
<entry>&Description;</entry>
93
+
</row>
94
+
</thead>
95
+
<tbody>
96
+
<row>
97
+
<entry>8.1.0</entry>
98
+
<entry>
99
+
Returns an <classname>FTP\Connection</classname> instance now;
100
+
previously, a &resource; was returned.
101
+
</entry>
102
+
</row>
103
+
</tbody>
104
+
</tgroup>
105
+
</informaltable>
103
106
</refsect1>
104
107

105
108
<refsect1 role="examples">
...
...
@@ -112,15 +115,20 @@
112
115
<?php
113
116

114
117
// set up basic ssl connection
115
-
$conn_id = ftp_ssl_connect($ftp_server);
118
+
$ftp = ftp_ssl_connect($ftp_server);
116
119

117
120
// login with username and password
118
-
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
121
+
$login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass);
119
122

120
-
echo ftp_pwd($conn_id); // /
123
+
if (!$login_result) {
124
+
// PHP will already have raised an E_WARNING level message in this case
125
+
die("can't login");
126
+
}
127
+

128
+
echo ftp_pwd($ftp);
121
129

122
130
// close the ssl connection
123
-
ftp_close($conn_id);
131
+
ftp_close($ftp);
124
132
?>
125
133
]]>
126
134
</programlisting>
...
...
@@ -136,7 +144,6 @@ ftp_close($conn_id);
136
144
</para>
137
145
</refsect1>
138
146
</refentry>
139
-

140
147
<!-- Keep this comment at the end of the file
141
148
Local variables:
142
149
mode: sgml
143
150