ftp_rawlist

(PHP 4, PHP 5, PHP 7, PHP 8)

ftp_rawlist返回指定目录下文件的详细列表

说明

ftp_rawlist(resource $ftp_stream, string $directory, bool $recursive = false): array

ftp_rawlist() 函数将执行 FTP LIST 命令,并把结果做为一个数组返回。

参数

ftp_stream

FTP 连接资源。

directory

要操作的目录路径,可以包括 LIST 参数。

recursive

如果此参数为 true,实际执行的命令将会为 LIST -R

返回值

返回一个数组,数组的每个元素为返回文本的每一行,输出结构不会被解析。使用函数 ftp_systype() 可以用来判断 FTP 服务器的类型,从而可以用来判断返回列表的类型。

The output is not parsed in any way. The system type identifier returned by ftp_systype() can be used to determine how the results should be interpreted.

范例

示例 #1 ftp_rawlist() 示例

<?php

// 初始化连接
$conn_id ftp_connect($ftp_server);

// 使用用户名和密码登录
$login_result ftp_login($conn_id$ftp_user_name$ftp_user_pass);

// 获取 / 路径下的文件列表
$buff ftp_rawlist($conn_id'/');

// 关闭连接
ftp_close($conn_id);

// 输出
var_dump($buff);
?>

以上例程的输出类似于:

array(3) {
  [0]=>
  string(65) "drwxr-x---   3 vincent  vincent      4096 Jul 12 12:16 public_ftp"
  [1]=>
  string(66) "drwxr-x---  15 vincent  vincent      4096 Nov  3 21:31 public_html"
  [2]=>
  string(73) "lrwxrwxrwx   1 vincent  vincent        11 Jul 12 12:16 www -> public_html"
}

参见

7i24.Com