一、fopen() fwrite() fclose() fiel_put_contents
html
1)fopen(path,′xx′)打开一个文件xx=r是以只读的方式打开并将指针指向头部xx=r+读写方式打开xx=w写入方式,并清空文件内容,指针执行头部,不存在则建立xx=w+读写方式,后面同上xx=a写入方式并将指针执行头部,可是写入会覆盖以前存在内容,若是不存在则建立xx=a+读写方式,其余同上2)fwrite(缓存
handle,content) 向文件中写入文字
3)flcose($path) 关闭文件
4)file_put_contents('file',content) 向文件中写入内容并发
应用场景:作文件的缓存以及作网站的日志记录等ide
二、fread() feof() fgets() fgetss() fgetc() file_get_contents() file()
测试
1)fread(handle,网站
size) 从一个文件中获取指定字节大写的内容
2)feof($handle) 判断指针是否已经到达尾部
3)fgets() 从文件中读取一行
4)fgetss() 读取一行并过来html
4)fgetc() 从文件中读取一个字符
5)file_get_contents() 从一个文件句柄里面获取内容
6)file() 同上指针
应用场景:并发不是很高的状况下能够配置文件锁的机制作队列功能日志
for example: handle=fopen(′1.txt′,′r′);while(!feof( handle)){ echo fgetc($handle); } fclose($handle);
三、file_exists()code
1) file_exists() 检查文件或者目录是否存在htm
应用场景,咱们作图片上传的时候,判断目录是否存在,若是不存在就建立
for example: handle=′uploads/test′;if(!fileexists( handle)){ mkdir($handle,0777,true); }
四、is_dir() is_file() is_link() is_readable() is_writeable() is_writable() is_uploaded_file() is_executable()
1)is_dir() 是不是一个目录
2)is_file() 是不是一个文件
应用场景:咱们在循环遍历一个目录的时候,能够判断是不是目录,若是是将递归遍历
五、copy() move_uploaded_file() rename() 1)copy(one, two) 2)move_uploaded_file()
应用场景:上传图片,移动临时文件到指定的目录
3)rename() 六、filesize() filetype()
1)filesize() 获取文件的大小
2)filetype() 获取文件的类型
七、pathinfo()
1)pathinfo() 返回路径的信息
八、dirname() basename()
1)dirname() 返回路径中的目录部分
2)basename() 返回路径中的文件部分
九、fileatime() filemtime() filectime() touch()
1)fileatime() 获取文件的上次访问时间
2)filemtime() 获取文件的修改时间
3)filectime() 获取文件的修改时间
4)touch() 设置文件的访问和修改时间
十、mkdir() unlink() rmdir()
1)mkdir(path,0777,true)建立文件2)unlink(
file) 删除文件
3)rmdir() 删除目录
十一、feof() fseek() rewind() ftell()
1)feof() 测试文件是否到了文件文件结束的位置2)fsweek() 在文件中指针中定位3)rewind() 倒回文件指针的位置4)ftell() 返回文件读写的位置