array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), 'this' => array ( 0 => 'function.ftp-nlist.php', 1 => 'ftp_nlist', ), 'up' => array ( 0 => 'ref.ftp.php', 1 => 'FTP 関数', ), 'prev' => array ( 0 => 'function.ftp-nb-put.php', 1 => 'ftp_nb_put', ), 'next' => array ( 0 => 'function.ftp-pasv.php', 1 => 'ftp_pasv', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'ja', 'path' => 'reference/ftp/functions/ftp-nlist.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
ftp_nlist — 指定したディレクトリのファイルの一覧を返す
ftp
FTP\Connection クラスのインスタンス
directory
一覧を表示するディレクトリ。このパラメータには引数を含めることができます。
例: ftp_nlist($ftp, "-la /your/dir");
このパラメータはエスケープ処理されません。スペースやその他の文字を含む
ファイル名では問題が発生する可能性があることに注意してください。
成功した場合は指定したディレクトリ内のファイル名の配列を、
エラー時には false
を返します。
バージョン | 説明 |
---|---|
8.1.0 |
引数 ftp は、FTP\Connection
のインスタンスを期待するようになりました。
これより前のバージョンでは、リソース を期待していました。
|
例1 ftp_nlist() の例
<?php
// 接続を確立する
$ftp = ftp_connect($ftp_server);
// ユーザー名とパスワードでログインする
$login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass);
// カレントディレクトリの内容を得る
$contents = ftp_nlist($ftp, ".");
// $contents を出力する
var_dump($contents);
?>
上の例の出力は、 たとえば以下のようになります。
array(3) { [0]=> string(11) "public_html" [1]=> string(10) "public_ftp" [2]=> string(3) "www"