= 4.0.3, PHP 5, PHP 7, PHP 8)ftp_exec — 在 FTP 服務(wù)器運(yùn)行指定的命令說明ftp_exec(resource $ftp_stream, string $command): bool發(fā)送一個(gè) SITE EXEC command ">

ftp_exec

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

ftp_exec在 FTP 服務(wù)器運(yùn)行指定的命令

說明

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

發(fā)送一個(gè) SITE EXEC command 請求到 FTP 服務(wù)器。

參數(shù)

ftp_stream

FTP 連接資源句柄。

command

要執(zhí)行的命令。

返回值

如果執(zhí)行成功(服務(wù)器發(fā)送響應(yīng)代碼 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);

?>

參見

  • ftp_raw() - 向 FTP 服務(wù)器發(fā)送命令