连接、登录和关闭 FTP 连接:
<?php
// connect to FTP server
$ftp_server = "ftp.example.com";
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
// login
if (@ftp_login($ftp_conn, $ftp_username, $ftp_userpass))
{
echo "Connection established.";
}
else
{
echo "Couldn't establish a connection.";
}
// do something...
// close connection
ftp_close($ftp_conn);
?>
ftp_login() 函数登录到指定的 FTP 连接。
ftp_login(
ftp_conn, username, password);
Parameter | Description |
---|---|
ftp_conn | Required. Specifies the FTP connection to use |
username | Required. Specifies the username to login with |
password | Required. Specifies the password to login with |
返回值: | TRUE 表示成功,FALSE 表示失败并发出警告 |
---|---|
PHP 版本: | 4+ |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!