PHP 中的 ftp_exec() 函数


ftp_exec() 函数用于在 FTP 服务器上执行命令。

语法

ftp_exec(con, command)

参数

  • con − FTP 连接

  • command − 要执行的命令。

返回值

如果命令执行成功,ftp_exec() 函数返回 TRUE;否则,返回 FALSE。

示例

以下是一个在 FTP 服务器上执行命令的示例 −

<?php
   $ftp_server="192.168.0.4";
   $ftp_user="amit";
   $ftp_pass="tywg61gh";
   $con = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
   // list all the files of the remote directory
   $command = 'ls';
   // execute command
   if (ftp_exec($con,$command)) {
      echo "Executed successfully!";
   } else {
      echo "Execution failed!";
   }
   ftp_close($con);
?>

更新于: 30-Jul-2019

179 次浏览

开启你的 职业生涯

完成该课程以获得认证

开始学习
广告
© . All rights reserved.