PHP ftp_connect()関数
例
FTP接続に接続し、ログインして、閉じます。
<?php
// connect and login to FTP server
$ftp_server = "ftp.example.com";
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);
// then do something...
// close connection
ftp_close($ftp_conn);
?>
定義と使用法
ftp_connect()関数は、指定されたホストへのFTP接続を開きます。
接続が開いているときは、サーバーに対してFTP機能を実行できます。
構文
ftp_connect(host, port, timeout);
パラメータ値
Parameter | Description |
---|---|
host | Required. Specifies the FTP server to connect to. Can be a domain address or an IP address. This parameter should not be prefixed with "ftp://" or have any trailing slashes |
port | Optional. Specifies the port of the FTP server. Default is port 21 |
timeout | Optional. Specifies the timeout for all subsequent network operations. Default is 90 seconds |
技術的な詳細
戻り値: | 成功した場合はFTPストリーム、エラーの場合はFALSE |
---|---|
PHPバージョン: | 4歳以上 |
PHP変更ログ: | タイムアウトパラメータはPHP4.2.0で追加されました |
❮PHPFTPリファレンス