在 FTP 伺服器執行指定的命令

ftp_exec

(PHP 4 >= 4.0.3, PHP 5, PHP 7, PHP 8)

ftp_exec在 FTP 伺服器執行指定的命令

說明

ftp_exec(resource $ftp_stream, string $command): bool

發送一個 SITE EXEC command 請求到 FTP 伺服器。

參數

ftp_stream

FTP 連線資源控制代碼。

command

要執行的命令。

返回值

如果執行成功(伺服器發送響應程式碼 200)則返回 true;否則返回 false

範例

示例 #1 ftp_exec() 示例

<?php

// variable initialization
$command 'ls -al >files.txt';

// set up basic connection
$conn_id ftp_connect($ftp_server);

// login with username and password
$login_result ftp_login($conn_id$ftp_user_name$ftp_user_pass);

// execute command
if (ftp_exec($conn_id$command)) {
    echo 
"$command executed successfully\n";
} else {
    echo 
"could not execute $command\n";
}

// close the connection
ftp_close($conn_id);

?>

參見

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *