Hàm ftp_connect() của PHP
Ví dụ
Kết nối, đăng nhập và đóng kết nối FTP:
<?php
// connect and login to FTP server
$ftp_server = "ftp.example.com";
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);
// then do something...
// close connection
ftp_close($ftp_conn);
?>
Định nghĩa và cách sử dụng
Hàm ftp_connect() mở kết nối FTP tới máy chủ được chỉ định.
Khi kết nối được mở, bạn có thể chạy các chức năng FTP đối với máy chủ.
Cú pháp
ftp_connect( host, port, timeout );
Giá trị tham số
Parameter | Description |
---|---|
host | Required. Specifies the FTP server to connect to. Can be a domain address or an IP address. This parameter should not be prefixed with "ftp://" or have any trailing slashes |
port | Optional. Specifies the port of the FTP server. Default is port 21 |
timeout | Optional. Specifies the timeout for all subsequent network operations. Default is 90 seconds |
Chi tiết kỹ thuật
Giá trị trả về: | Luồng FTP thành công hoặc FALSE bị lỗi |
---|---|
Phiên bản PHP: | 4+ |
Nhật ký thay đổi PHP: | Tham số thời gian chờ đã được thêm vào PHP 4.2.0 |
❮ Tham khảo FTP PHP