Latest web development tutorials

PHP ftp_connect () function

PHP FTP Reference Complete PHP FTP Reference

Definition and Usage

ftp_connect () function to open an FTP connection.

When the connection is open, you can run the FTP server function by.

grammar

ftp_connect(host,port,timeout)

参数 描述
host 必需。规定要连接的 FTP 服务器。可以是域名地址或 IP 地址。该参数不能包含 "ftp://" 或者斜线。
port 可选。规定 FTP 服务器的端口。默认是 21。
timeout 可选。规定该 FTP 连接的超时时间。默认是 90 秒。


Examples

This example attempts to connect to an FTP server. If the connection fails, you die () function to terminate the script, and outputs a message:

<?php
$conn = ftp_connect("ftp.testftp.com") or die("Could not connect");
?>


PHP FTP Reference Complete PHP FTP Reference