略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: ftp_exec

2024-04-28

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);

?>

参见

add a noteadd a note

User Contributed Notes 1 note

up
1
sam at totallydigital dot co dot nz
18 years ago
A word of caution, execution via FTP isn't very widely supported.  Check that it works on the servers that you intend to connect to before you start coding something that requires this.

官方地址:https://www.php.net/manual/en/function.ftp-exec.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3