PHP ftp_connect()ฟังก์ชั่น
ตัวอย่าง
เชื่อมต่อ เข้าสู่ระบบ และปิดการเชื่อมต่อ 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);
?>
ความหมายและการใช้งาน
ฟังก์ชัน ftp_connect() เปิดการเชื่อมต่อ FTP ไปยังโฮสต์ที่ระบุ
เมื่อเปิดการเชื่อมต่อ คุณสามารถเรียกใช้ฟังก์ชัน FTP กับเซิร์ฟเวอร์ได้
ไวยากรณ์
ftp_connect(host, port, timeout);
ค่าพารามิเตอร์
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 |
รายละเอียดทางเทคนิค
คืนมูลค่า: | สตรีม FTP สำเร็จหรือ FALSE จากข้อผิดพลาด |
---|---|
รุ่น PHP: | 4+ |
บันทึกการเปลี่ยนแปลง PHP: | เพิ่มพารามิเตอร์ การหมดเวลาใน PHP 4.2.0 |
❮ การอ้างอิง PHP FTP