ftp_connect
Open the FTP connection.
ftp_connect()
function establishes a new FTP connection.
If successful, a connection identifier is returned, otherwise false is returned.
This example attempts to connect to an FTP server. If the connection fails, the die() function terminates the script and outputs a message:
<?php $conn = ftp_connect ( "ftp.testftp.com" ) or die ( "Could not connect" ) ; ?>
ftp_connect ( host , port , timeout )
parameter | describe |
---|---|
host |
Required. Specifies the FTP server to connect to. Can be a domain name or an IP address. The back should not end with a slash, and the front should not start with ftp://. |
port | Optional. Specifies the port of the FTP server. |
timeout | Optional. Specifies the timeout time of the FTP server. The default is 90 seconds. |
Tip: The timeout time can be changed and obtained at any time through the functions ftp_set_option() and ftp_get_option() .
The parameter timeout is only available for PHP 4.2.0 and above.