目录

PHP ftp_login() 函数

❮ PHP FTP 参考

示例

连接、登录和关闭 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+

❮ PHP FTP 参考