Heim  >  Artikel  >  Backend-Entwicklung  >  PHP文件处理

PHP文件处理

WBOY
WBOYOriginal
2016-06-23 14:31:141136Durchsuche

这是我在学习php过程中做的笔记,为了可以有一个良好的学习习惯,也为了给广大的编程爱好者一个学习的参考,特把学习笔记分享出来,希望对自己和大家都有帮助。本学习资料主要来自于LAMP兄弟连的细说PHP,PHP5中文手册和网上资料,强烈推荐有志于学习PHP的朋友选择LAMP兄弟连的《细说PHP》

文件判断函数

is_dir()

is_executable()      判断是否是可执行文件

is_file()

is_link()                   判断文件名是否为一个符号连接

is_readable()

is_uploader_fiel()     判断文件是否通过HTTP POST上传

is_writable()

 

文件属性

file_exists()

filesize()

is_readable()

is_writeable()

filectime()

filemtime()

 

取文件名 basename()

取目录     dirname()

文件路径信息  pathinfo()

 

创建文件  touch($file)

删除文件  unlink($file)

移动文件(重命名文件)   rename(“当前文件路径","目标文件路径")

复制文件   copy(“文件名",”路径")

 

读写文件

file_get_contents()

file_put_contents()

 

fopen(“URL”,模式)

各种模式:

r: 只读模式打开文件 r+:读写模式 w:  只写模式打开,若文件不存在,则新建,若文件已有内容,则覆盖 w+ :读写模式 a:   只写模式打开,若文件不存在,则新建,若文件已有内容,则追加 a+:读写模式 b :以二进制模式打开文件(图片,视频) t :以文本模式打开文件

     fread()    //读取指定长度的字符;fread(“$file”,filesize(“text.txt”))

     fgetc()     //一次从文件中读取一个字符;

     fgets()     //一次从文件中读取一行字符;

     feof($file)  //读取文件出错或到文件结束则返回真

写入文件

fwrite()

 

文件内部移动指针

ftell($file)  //返回当前指针位置

fseek($file,100,常量)      //移动文件指针

rewind()

 

basename(文件路径[,文件后缀名])         获取文件名,第二个参数为获取文件基本名称 pathinfo(文件路径)   分析当前路径,返回一个关联数组,通过dirname,basename,extension来引用 realpath(文件相对路径)     显示文件绝对路径 filesize($file)        计算文件大小 fileatime($file)       显示最后一次被访问的时间 filectime($file)        文件建立时间 filemtime($file)        文件最后一个更新 fileperms()       返回文件属性以及权限 fileowner()       取得文件所有者

 

目录操作:

opendir()   readdir()    closedir() rewinddir()     //指针返回第一个目录
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:[PHP]初学笔记Nächster Artikel:php中foreach()的用法