🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
编译此扩展无需任何额外的库,但想要 PHP 支持 Linux 的 LFS(large files),需要最新的 glibc,并在编译 PHP 时带上以下标记:*\-D\_LARGEFILE\_SOURCE -D\_FILE\_OFFSET\_BITS=64*。 * [预定义常量](https://www.php.net/manual/zh/filesystem.constants.php) * [文件系统函数](https://www.php.net/manual/zh/ref.filesystem.php) * [basename](https://www.php.net/manual/zh/function.basename.php)— 返回路径中的文件名部分 * [chgrp](https://www.php.net/manual/zh/function.chgrp.php)— 改变文件所属的组 * [chmod](https://www.php.net/manual/zh/function.chmod.php)— 改变文件模式 * [chown](https://www.php.net/manual/zh/function.chown.php)— 改变文件的所有者 * [clearstatcache](https://www.php.net/manual/zh/function.clearstatcache.php)— 清除文件状态缓存 * [copy](https://www.php.net/manual/zh/function.copy.php)— 拷贝文件 * [delete](https://www.php.net/manual/zh/function.delete.php)— 参见 unlink 或 unset * [dirname](https://www.php.net/manual/zh/function.dirname.php)— 返回路径中的目录部分 * [disk\_free\_space](https://www.php.net/manual/zh/function.disk-free-space.php)— 返回目录中的可用空间 * [disk\_total\_space](https://www.php.net/manual/zh/function.disk-total-space.php)— 返回一个目录的磁盘总大小 * [diskfreespace](https://www.php.net/manual/zh/function.diskfreespace.php)— disk\_free\_space 的别名 * [fclose](https://www.php.net/manual/zh/function.fclose.php)— 关闭一个已打开的文件指针 * [feof](https://www.php.net/manual/zh/function.feof.php)— 测试文件指针是否到了文件结束的位置 * [fflush](https://www.php.net/manual/zh/function.fflush.php)— 将缓冲内容输出到文件 * [fgetc](https://www.php.net/manual/zh/function.fgetc.php)— 从文件指针中读取字符 * [fgetcsv](https://www.php.net/manual/zh/function.fgetcsv.php)— 从文件指针中读入一行并解析 CSV 字段 * [fgets](https://www.php.net/manual/zh/function.fgets.php)— 从文件指针中读取一行 * [fgetss](https://www.php.net/manual/zh/function.fgetss.php)— 从文件指针中读取一行并过滤掉 HTML 标记 * [file\_exists](https://www.php.net/manual/zh/function.file-exists.php)— 检查文件或目录是否存在 * [file\_get\_contents](https://www.php.net/manual/zh/function.file-get-contents.php)— 将整个文件读入一个字符串 * [file\_put\_contents](https://www.php.net/manual/zh/function.file-put-contents.php)— 将一个字符串写入文件 * [file](https://www.php.net/manual/zh/function.file.php)— 把整个文件读入一个数组中 * [fileatime](https://www.php.net/manual/zh/function.fileatime.php)— 取得文件的上次访问时间 * [filectime](https://www.php.net/manual/zh/function.filectime.php)— 取得文件的 inode 修改时间 * [filegroup](https://www.php.net/manual/zh/function.filegroup.php)— 取得文件的组 * [fileinode](https://www.php.net/manual/zh/function.fileinode.php)— 取得文件的 inode * [filemtime](https://www.php.net/manual/zh/function.filemtime.php)— 取得文件修改时间 * [fileowner](https://www.php.net/manual/zh/function.fileowner.php)— 取得文件的所有者 * [fileperms](https://www.php.net/manual/zh/function.fileperms.php)— 取得文件的权限 * [filesize](https://www.php.net/manual/zh/function.filesize.php)— 取得文件大小 * [filetype](https://www.php.net/manual/zh/function.filetype.php)— 取得文件类型 * [flock](https://www.php.net/manual/zh/function.flock.php)— 轻便的咨询文件锁定 * [fnmatch](https://www.php.net/manual/zh/function.fnmatch.php)— 用模式匹配文件名 * [fopen](https://www.php.net/manual/zh/function.fopen.php)— 打开文件或者 URL * [fpassthru](https://www.php.net/manual/zh/function.fpassthru.php)— 输出文件指针处的所有剩余数据 * [fputcsv](https://www.php.net/manual/zh/function.fputcsv.php)— 将行格式化为 CSV 并写入文件指针 * [fputs](https://www.php.net/manual/zh/function.fputs.php)— fwrite 的别名 * [fread](https://www.php.net/manual/zh/function.fread.php)— 读取文件(可安全用于二进制文件) * [fscanf](https://www.php.net/manual/zh/function.fscanf.php)— 从文件中格式化输入 * [fseek](https://www.php.net/manual/zh/function.fseek.php)— 在文件指针中定位 * [fstat](https://www.php.net/manual/zh/function.fstat.php)— 通过已打开的文件指针取得文件信息 * [ftell](https://www.php.net/manual/zh/function.ftell.php)— 返回文件指针读/写的位置 * [ftruncate](https://www.php.net/manual/zh/function.ftruncate.php)— 将文件截断到给定的长度 * [fwrite](https://www.php.net/manual/zh/function.fwrite.php)— 写入文件(可安全用于二进制文件) * [glob](https://www.php.net/manual/zh/function.glob.php)— 寻找与模式匹配的文件路径 * [is\_dir](https://www.php.net/manual/zh/function.is-dir.php)— 判断给定文件名是否是一个目录 * [is\_executable](https://www.php.net/manual/zh/function.is-executable.php)— 判断给定文件名是否可执行 * [is\_file](https://www.php.net/manual/zh/function.is-file.php)— 判断给定文件名是否为一个正常的文件 * [is\_link](https://www.php.net/manual/zh/function.is-link.php)— 判断给定文件名是否为一个符号连接 * [is\_readable](https://www.php.net/manual/zh/function.is-readable.php)— 判断给定文件名是否可读 * [is\_uploaded\_file](https://www.php.net/manual/zh/function.is-uploaded-file.php)— 判断文件是否是通过 HTTP POST 上传的 * [is\_writable](https://www.php.net/manual/zh/function.is-writable.php)— 判断给定的文件名是否可写 * [is\_writeable](https://www.php.net/manual/zh/function.is-writeable.php)— is\_writable 的别名 * [lchgrp](https://www.php.net/manual/zh/function.lchgrp.php)— 修改符号链接的所有组 * [lchown](https://www.php.net/manual/zh/function.lchown.php)— 修改符号链接的所有者 * [link](https://www.php.net/manual/zh/function.link.php)— 建立一个硬连接 * [linkinfo](https://www.php.net/manual/zh/function.linkinfo.php)— 获取一个连接的信息 * [lstat](https://www.php.net/manual/zh/function.lstat.php)— 给出一个文件或符号连接的信息 * [mkdir](https://www.php.net/manual/zh/function.mkdir.php)— 新建目录 * [move\_uploaded\_file](https://www.php.net/manual/zh/function.move-uploaded-file.php)— 将上传的文件移动到新位置 * [parse\_ini\_file](https://www.php.net/manual/zh/function.parse-ini-file.php)— 解析一个配置文件 * [parse\_ini\_string](https://www.php.net/manual/zh/function.parse-ini-string.php)— 解析配置字符串 * [pathinfo](https://www.php.net/manual/zh/function.pathinfo.php)— 返回文件路径的信息 * [pclose](https://www.php.net/manual/zh/function.pclose.php)— 关闭进程文件指针 * [popen](https://www.php.net/manual/zh/function.popen.php)— 打开进程文件指针 * [readfile](https://www.php.net/manual/zh/function.readfile.php)— 输出文件 * [readlink](https://www.php.net/manual/zh/function.readlink.php)— 返回符号连接指向的目标 * [realpath\_cache\_get](https://www.php.net/manual/zh/function.realpath-cache-get.php)— 获取真实目录缓存的详情 * [realpath\_cache\_size](https://www.php.net/manual/zh/function.realpath-cache-size.php)— 获取真实路径缓冲区的大小 * [realpath](https://www.php.net/manual/zh/function.realpath.php)— 返回规范化的绝对路径名 * [rename](https://www.php.net/manual/zh/function.rename.php)— 重命名一个文件或目录 * [rewind](https://www.php.net/manual/zh/function.rewind.php)— 倒回文件指针的位置 * [rmdir](https://www.php.net/manual/zh/function.rmdir.php)— 删除目录 * [set\_file\_buffer](https://www.php.net/manual/zh/function.set-file-buffer.php)— stream\_set\_write\_buffer 的别名 * [stat](https://www.php.net/manual/zh/function.stat.php)— 给出文件的信息 * [symlink](https://www.php.net/manual/zh/function.symlink.php)— 建立符号连接 * [tempnam](https://www.php.net/manual/zh/function.tempnam.php)— 建立一个具有唯一文件名的文件 * [tmpfile](https://www.php.net/manual/zh/function.tmpfile.php)— 建立一个临时文件 * [touch](https://www.php.net/manual/zh/function.touch.php)— 设定文件的访问和修改时间 * [umask](https://www.php.net/manual/zh/function.umask.php)— 改变当前的 umask * [unlink](https://www.php.net/manual/zh/function.unlink.php)— 删除文件 ****fopen()**中`mode`的可能值列表** | `mode` | 说明 | | --- | --- | | *'r'* | 只读方式打开,将文件指针指向文件头。 | | *'r+'* | 读写方式打开,将文件指针指向文件头。 | | *'w'* | 写入方式打开,将文件指针指向文件头并清除文件内容。如果文件不存在则尝试创建之。 | | *'w+'* | 读写方式打开,将文件指针指向文件头并清除文件内容。如果文件不存在则尝试创建之。 | | *'a'* | 写入方式打开,将文件指针指向文件末尾。如果文件不存在则尝试创建之。 | | *'a+'* | 读写方式打开,将文件指针指向文件末尾。如果文件不存在则尝试创建之。 | | *'x'* | 创建并以写入方式打开,将文件指针指向文件头。如果文件已存在,则**fopen()**调用失败并返回**`FALSE`**,并生成一条**`E_WARNING`**级别的错误信息。如果文件不存在则尝试创建之。这和给 底层的*open(2)*系统调用指定*O\_EXCL|O\_CREAT*标记是等价的。 | | *'x+'* | 创建并以读写方式打开,其他的行为和*'x'*一样。 | | *'c'* |写入方式打开,鼠标指向文件头部,每次新增只是替换文件的第一行 | | *'c+'* | Open the file for reading and writing; otherwise it has the same behavior as*'c'*. |