Computer >> Máy Tính >  >> Lập trình >> PHP

hàm ftp_exec () trong PHP

Hàm ftp_exec () được sử dụng để thực thi một lệnh trên máy chủ FTP.

Cú pháp

ftp_exec(con, command)

Tham số

  • con - Kết nối FTP

  • lệnh - Lệnh thực thi.

Quay lại

Hàm ftp_exec () trả về TRUE nếu lệnh được thực thi thành công, nếu không, FALSE.

Ví dụ

Sau đây là một ví dụ thực thi một lệnh trên máy chủ 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);
?>