php 提供了多种函数来获取文件的信息,包括:检查文件是否存在:file_exists()检查文件类型:is_file(), is_dir()获取文件大小:filesize()获取文件日期:fileatime(), filectime(), filemtime()获取文件权限:fileperms(), fileowner(), filegroup()获取文件类型:filetype()获取文件 mime 类型:finfo_file()

PHP 获取文件信息
PHP 提供了一系列函数来获取有关文件的信息,这些信息包括:
文件存在
<code class="php">file_exists(string $filename)</code>
检查文件是否存在,返回布尔值。
立即学习“PHP免费学习笔记(深入)”;
文件类型
<code class="php">is_file(string $filename)</code>
检查文件是否为普通文件,返回布尔值。
<code class="php">is_dir(string $filename)</code>
检查文件是否为目录,返回布尔值。
文件大小
<code class="php">filesize(string $filename)</code>
返回文件的大小(以字节为单位)。
文件日期
<code class="php">fileatime(string $filename)</code>
返回文件最后访问的时间(以 Unix 时间戳为单位)。
<code class="php">filectime(string $filename)</code>
返回文件最后更改的时间(以 Unix 时间戳为单位)。
<code class="php">filemtime(string $filename)</code>
返回文件最后修改的时间(以 Unix 时间戳为单位)。
文件权限
<code class="php">fileperms(string $filename)</code>
返回文件的权限(以十进制数表示)。
<code class="php">fileowner(string $filename)</code>
返回文件所有者的用户 ID。
<code class="php">filegroup(string $filename)</code>
返回文件所有者的组 ID。
文件类型
<code class="php">filetype(string $filename)</code>
返回文件类型,例如 "file"、"dir" 或 "link"。
文件 MIME 类型
<code class="php">finfo_file(string $filename, int $flags = FILEINFO_MIME_TYPE)</code>
返回文件的 MIME 类型,例如 "text/plain" 或 "image/jpeg"。











