array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.ftp-mlsd.php', 1 => 'ftp_mlsd', ), 'up' => array ( 0 => 'ref.ftp.php', 1 => 'FTP 函数', ), 'prev' => array ( 0 => 'function.ftp-mkdir.php', 1 => 'ftp_mkdir', ), 'next' => array ( 0 => 'function.ftp-nb-continue.php', 1 => 'ftp_nb_continue', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/ftp/functions/ftp-mlsd.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 7 >= 7.2.0, PHP 8)
ftp_mlsd — 返回指定目录中的文件列表
如果成功,则返回一个由目录中所有文件信息(数组)所组成的数组;如果错误,则返回 false
。
版本 | 说明 |
---|---|
8.1.0 |
现在 ftp 参数接受 FTP\Connection
实例,之前接受 resource。
|
示例 #1 ftp_mlsd() 示例
<?php
// 简单基本连接
$ftp = ftp_connect($ftp_server);
// 使用用户名和密码进行登录
$login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass);
// 获取当前目录的内容
$contents = ftp_mlsd($ftp, ".");
// 输出 $contents
var_dump($contents);
?>
以上示例的输出类似于:
array(5) { [0]=> array(8) { ["name"]=> string(1) "." ["modify"]=> string(14) "20171212154511" ["perm"]=> string(7) "flcdmpe" ["type"]=> string(4) "cdir" ["unique"]=> string(11) "811U5740002" ["UNIX.group"]=> string(2) "33" ["UNIX.mode"]=> string(4) "0755" ["UNIX.owner"]=> string(2) "33" } [1]=> array(8) { ["name"]=> string(2) ".." ["modify"]=> string(14) "20171212154511" ["perm"]=> string(7) "flcdmpe" ["type"]=> string(4) "pdir" ["unique"]=> string(11) "811U5740002" ["UNIX.group"]=> string(2) "33" ["UNIX.mode"]=> string(4) "0755" ["UNIX.owner"]=> string(2) "33" } [2]=> array(8) { ["name"]=> string(11) "public_html" ["modify"]=> string(14) "20171211171525" ["perm"]=> string(7) "flcdmpe" ["type"]=> string(3) "dir" ["unique"]=> string(11) "811U5740525" ["UNIX.group"]=> string(2) "33" ["UNIX.mode"]=> string(4) "0755" ["UNIX.owner"]=> string(2) "33" } [3]=> array(8) { ["name"]=> string(10) "public_ftp" ["modify"]=> string(14) "20171211174536" ["perm"]=> string(7) "flcdmpe" ["type"]=> string(3) "dir" ["unique"]=> string(11) "811U57405EE" ["UNIX.group"]=> string(2) "33" ["UNIX.mode"]=> string(4) "0755" ["UNIX.owner"]=> string(2) "33" } [4]=> array(8) { ["name"]=> string(3) "www" ["modify"]=> string(14) "www" ["perm"]=> string(7) "flcdmpe" ["type"]=> string(3) "dir" ["unique"]=> string(11) "811U5740780" ["UNIX.group"]=> string(2) "33" ["UNIX.mode"]=> string(4) "0755" ["UNIX.owner"]=> string(2) "33" } }