0

我正在为一个检索文件元信息的 PHP 项目工作。我只知道文件名、文件大小、修改日期。

有人知道我可以使用 PHP 进入文件的其他元信息吗?如果有,你会写下 PHP 代码吗?

4

1 回答 1

1

如果您要求元标记信息,请使用get_meta_tags()检索所有元信息。

<?php
// Assuming the above tags are at www.example.com
$tags = get_meta_tags('http://www.example.com/');

// Notice how the keys are all lowercase now, and
// how . was replaced by _ in the key.
echo $tags['author'];       // name
echo $tags['keywords'];     // php documentation
echo $tags['description'];  // a php manual
echo $tags['geo_position']; // 49.33;-86.59
?>

新编辑——

对于文件信息,您可以使用fstat()方法--

fstat — 使用打开的文件指针获取有关文件的信息

<?php
// open a file
$fp = fopen("/etc/passwd", "r");

// gather statistics
$fstat = fstat($fp);

// close the file
fclose($fp);

// print only the associative part
print_r(array_slice($fstat, 13));
?>

OUTPUT-

Array
(
    [dev] => 771
    [ino] => 488704
    [mode] => 33188
    [nlink] => 1
    [uid] => 0
    [gid] => 0
    [rdev] => 0
    [size] => 1114
    [atime] => 1061067181
    [mtime] => 1056136526
    [ctime] => 1056136526
    [blksize] => 4096
    [blocks] => 8
)
于 2012-06-21T03:46:02.767 回答