PHP操作目录与文件的一些函数
2011-04-19
PHP操作目录与文件在很多场合都用得到,也许你想写的功能早就有相应的函数封装好了。下面总结下一些常用的目录与文件的操作函数,看看你有没有曾经想实现的一些功能~
- 获取路径的文件名
- 获取路径的目录
- 了解更多的路径信息
- 确定绝对路径
- 确定文件的大小
- 计算磁盘的可用空间
- 计算磁盘的总容量
- 确定文件的最后访问时间
- 确定文件的最后改变时间
- 确定文件的最后修改时间
- 识别文件末尾字符
- 打开和关闭文件
- 将文件读入数组
- 将文件内容读入字符串变量
- 将CSV文件读入数组
- 读取指定数目的字符
- 从输入中剔除标记,清除所有HTML和PHP标记
- 以一次读取一个字符的方式读取文件
- 忽略换行符
- 读取整个文件
- 根据预定义的格式读取文件
- 将字符串写入文件
- 移动文件指针
- 打开目录句柄
- 关闭目录句柄
- 解析目录内容
- 将目录读入数组
- 删除目录
- 重命名文件
- 触摸文件
string basename(string path[,string suffix])
string dirname(string path)
array pathinfo(string path)
string realpath(string path)
int filesize(string filename)
float disk_free_space(string directory)
float disk_total_space(string directory)
int fileatime(string filename)
int filectime(string filename)
int filemtime(string filename)
int feof(string resource)
resource fopen(string resource,string mode[,int use_include_path[,resource zountext]]) boolean fclose(resource filehandle)
array file9string filename[,int user_inlucde_path[,resource context]])
string file_get_contents(string filename[,int use_inlude_path[resource context]])
array fgetcsv(resource handle[,int length[,string delimiter[,string enclosure]]])
string fgets(resource handle[,int length])
string fgetss(resourcce handle,int length[,string allowable_tags])
string fgetc(resource handle)
string freed(resource handle,int length)
int readfile(string filename[,int use_include_path])
mixed fscanf(resource handle,string format[,string var1])
int fwrite(resource handle,string string[,int length])
int fseek(resource handle,int offset[,int whence])
resource opendir(string path)
void closedir(resource directory_handle)
string readdir(resource directory_handle)
array scandir(string directory[,int sorting_order[,resource context]])
int rmdir(string dirname)
boolean rename(string olename,string newname)
int touch(sting filename[,int time[,int atime]])
~EOF~

