php ftp_close,PHP ftp_close()用法及代码示例

ftp_close()函数是PHP中的内置函数,用于关闭与指定FTP服务器或主机的现有FTP连接。

用法:

ftp_close( $ftp_connection );

参数:该函数接受单个参数$ftp_connection。它指定FTP连接以关闭FTP连接。

返回值:成功返回True,失败返回False。

注意:

此功能可用于PHP 4.0.0和更高版本。

以下示例无法在在线IDE上运行。因此,请尝试使用适当的ftp服务器名称在某些PHP托管服务器或localhost中运行。

以下示例程序旨在说明PHP中的ftp_close()函数:

范例1:

// Connect to FTP server

$ftp_server = "localhost";

// Establishing ftp connection

$ftp_connection = ftp_connect($ftp_server)

or die("Could not connect to $ftp_server");

if($ftp_connection) {

echo "Successfully connected to the ftp server!";

// Closing  connection

if(ftp_close($ftp_connection)) {

echo "
Connection closed Successfully!";

}

}

?>

输出:

Successfully connected to the ftp server!

Connection closed Successfully!

范例2:使用端口21连接到ftp服务器。

// Connect to FTP server

$ftp_server = "localhost";

// Establishing ftp connection

$ftp_connection = ftp_connect($ftp_server, 21)

or die("Could not connect to $ftp_server");

if($ftp_connection) {

echo "Successfully connected to the ftp server!";

// Closing  connection

if(ftp_close($ftp_connection)) {

echo "
Connection closed Successfully!";

}

}

?>

输出:

Successfully connected to the ftp server!

Connection closed Successfully!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值