Javatpoint Logo
Javatpoint Logo

PHP ftp_connect() Function

The ftp_connect() function opens an FTP connection to a server. When the connection is open, you can run FTP functions against the server. This function was introduced in PHP 4.

Syntax:

Parameter Description Is compulsory
host This parameter should not have any trailing slashes and should not be prefixed with FTP. compulsory
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. Optional
timeout Specifies the timeout for all subsequent network operations and the default time of FTP is 90 seconds. Optional

Returns

The ftp_connect function returns a FTP connection on success otherwise an error.

Example 1

The example tries to connect to an FTP server. If the connection fails, the die() function terminates the script.

Example 2

Output:

If connected it gives
successful connected
If not connected it gives
not connected

Example 3

The above example tries to connect to an ftp server. If the connection don't success the control goes to die function.


Next TopicPHP FTP





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA