FTP ftp_exec

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

ftp_exec — FTP 서버에서 명령 실행을 요청합니다.


설명

ftp_exec(FTP\Connection $ftp, string $command): bool

FTP 서버에 SITE EXEC command 요청을 보냅니다.


매개변수

ftp
FTP\Connection 인스턴스입니다.
command
실행할 명령입니다.

반환 값

명령이 성공하면 true를 반환합니다(서버에서 응답 코드: 200 전송). 그렇지 않으면 false를 반환합니다.


변경 로그

버전 설명
8.1.0 ftp 매개변수는 이제 FTP\Connection 인스턴스를 필요로 합니다. 이전에는 리소스가 필요했습니다.

Examples

예제 #1 ftp_exec() 예제

                  
<?php

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

// set up basic connection
$ftp = ftp_connect($ftp_server);

// login with username and password
$login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass);

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

// close the connection
ftp_close($ftp);

?>
                  
                

기타

  • ftp_raw() - FTP 서버에 임의의 명령을 보냅니다.