Introduction
I will explain the ftp_connect() and ftp_close() functions in PHP. I will first describe the ftp_connect() function. The ftp_connect() function opens an FTP connection. This example is showm in the following.
Syntax
|
ftp_connect(host, port, timeout); |
| Parameter | Description |
| host | This parameter should not have any trailing slashes and should not be prefixed with FTP. |
| port | This parameter specifies an alternate port to connect to FTP. If it is omitted or set to zero, then the default FTP port, 21, will be used. |
| timeout | Specifies the timeout for all subsequent network operations and the default time of FTP is 90 seconds. |
Returns a FTP connection on success and otherwise an error.
Example
<?php
$ftp_conn="www.c-sharpcorner.com";
$conn_id = ftp_connect($ftp_conn) or die("Couldn't connect to $ftp_server");
if (!ftp_connect($ftp_conn))
echo "not connected";


Comments
Join the conversation! Your thoughts help the community grow.