FILE函数

int fopen(string filename, string mode) 打开文件

r:只读 文件头
r+:读写 文件头
w:写入 文件头
a:写入 文件尾
a+:读写 文件尾

fwrite(resource handle, string content, [int length]) 写到文件

fputs

string fread(int handle, int length) 读入内容

int filesize(string filename) 文件大小

bool fclose(resource handle) 关闭文件

string basename(string path) 取文件名

bool chgrp(string filename, mixed group) 更改文件所属组

bool chmod(string filename, int mode) 更改文件属性

bool chown(string filename, mixed user) 更改文件所有者

bool copy(string source, string dest) 拷贝文件

bool unlink(string filename) 删除文件

string dirname(string path) 取路径

float disk_free_space(string directory) 返回目录可用空间

diskfreespace

float disk_total_space(string directory) 返回总空间

bool feof(resource handle) 测试指针是否到文件尾

bool fflush(resource handle) 将缓冲内容输出到文件

string fgetc(resource handle) 从当前指针读取字符

string fgets(int handle) 从当前指针读取一行

string fgetss(resource handle) 从当前指针读取一行并过滤HTML标记

bool file_exists(string filename) 检查文件或目录是否存在

string file_get_contents(string filename) 将整个文件读入字符串

int file_put_contents(string filename, string date) 将字符串写到文件

array file(string filename) 把文件读入数组 (每行)

int fileatime(string filename) 取得文件上次访问时间

int filectime(string filename) inode 上次访问时间

int filegroup(string filename) 取得文件所在组ID

int fileinode(string filename) 返回文件的inode节点号

int filemtime(string filename) 取文件修改时间

int fileowner(string filename) 取得文件拥有者ID

int fileperms(string filename) 返回文件访问权限

string filetype(string filename) 返回文件的类型

bool flock(int handle, int operation) 锁定文件

bool fnmatch(string pattern, string string) 正则匹配文件名

int fpassthru(resource handle) 输出文件指针处的所有剩余数据

mixed fscanf(resource handle, string format) 从文件中格式化输入

$handle = fopen("users.txt","r");
while ($userinfo = fscanf($handle, "%s\t%s\t%s\n")) {
list ($name, $profession, $countrycode) = $userinfo;
//... do something with the values
}
fclose($handle);
?>

int fseek(resource handle, int offset) 文件指针定位

array fstat(resource handle) 通过已打开的文件指针取得文件信息

int ftell(resource handle) 返回文件的指针位置(读写位置)

bool ftruncate(resource handle, int size) 将文件截断到size

array glob(string pattern [,int flags]) 寻找匹配的文件名

GLOB_MARK - 在每个返回的项目中加一个斜线
GLOB_NOSORT - 按照文件在目录中出现的原

始顺序返回(不排序)
GLOB_NOCHECK - 如果没有文件匹配则返回用于搜索的模式
GLOB_NOESCAPE - 反斜线不转义元字符
GLOB_BRACE - 扩充 {a,b,c} 来匹配 'a','b' 或 'c'
GLOB_ONLYDIR - 仅返回与模式匹配的目录项

bool is_dir(string filename) 是否目录

bool is_executable(string filename) 是否可执行

bool is_file(string filename) 是否文件

bool is_link(string filename) 是否快捷方式

bool is_readable(string filename) 文件是否可读

bool is_uploaded_file(string filename) 是否通过POST上传的文件

bool is_writable(string filename) 是否可写

is_writeable

bool lchgrp(string filename, mixed gruop) 更改 符号链接 文件的所属组

bool lchown(string filename, mixed user) 更改 符号链接 文件的所有者

bool link(string target, string link) 创建一个硬链接

int linkinfo(string path) 获取一个链接的信息 echo linkinfo('/vmlinuz'); // 835

array lstat(string filename) 给出一个文件或符号链接的信息

bool mkdir(string pathname) 创建一个目录

bool move_uploaded_file(string filename, string destination) 将一个上传的文件移动到新位置

array parse_ini_file(string filename) 解析一个 ini 配置文件

mixed pathinfo(string path) 返回文件路径的信息

int pclose(resource handle) 关闭进程文件指针

resource popen(string command, string mode) 打开进程文件指针

int readfile(string filename) 读入一个文件并写如到缓冲区

string readlink(string path) 返回符号链接指向的目标

string realpath(string path) 返回规范的绝对路径

bool rename(string oldname, string newname) 重命名一个文件或目录

bool rewind(resource handle) 将handle的文件指针设置到开头位置

bool rmdir(string dirname) 删除目录

array stat(string filename) 给出文件信息

bool symlink(string target, string link) 建立符号链接

string tempnam(string dir, string prefix) 建立一个具有唯一文件名的文件

resource tmpfile(void) 建立一个临时文件 w+ 模式

bool touch(string filename) 设定文件的访问时间和修改时间

int umask() 改变当前的umask


相关主题
相关文档
最新文档