PHP网站开发案例教程课件.ppt

  1. 1、本文档共178页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
*/180 6.1 文件操作 6.1.1 检查文件是否存在 函数file_exists()检查一个文件或目录是否存在: bool file_exists ( string filename ) 6.1.2 打开和关闭文件 1. 打开文件 用函数fopen()打开一个文件或URL: resource fopen ( string filename, string mode [, bool use_include_path [, resource zcontext]] ) 2. 关闭文件 使用fclose()函数关闭文件: bool fclose ( resource handle ) 6.1.3 写入文件 用fwrite()函数向文件写入数据: int fwrite ( resource handle, string str [, int length] ) 第6章目录 */180 6.1 文件操作 6.1.4 读取文件 1. 读取单个字符 string fgetc ( resource handle ) 2. 逐行读取数据 fgets()函数从文件中读取一行: string fgets ( int handle [, int length] ) fgetss()函数从文件中读取一行并过滤掉HTML标记: string fgetss ( resource handle [, int length [, string allowable_tags]] ) fgetcsv()函数从文件指针中读入一行并解析CSV字段: array fgetcsv ( int handle [, int length [, string delimiter [, string enclosure]]] ) 第6章目录 */180 6.1 文件操作 6.1.4 读取文件 3. 读取指定长度数据 用fread()函数可以从文件读取指定长度的数据: string fread ( int handle, int length ) 4. 读取整个文件 readfile()函数读取并输出一个文件的内容: int readfile ( string filename [, bool use_include_path [, resource context]] ) fpassthru()函数输出文件指针处所有的剩余数据: int fpassthru ( resource handle ) file()函数将整个文件读入一个数组中: array file ( string filename [, int use_include_path [, resource context]] ) file_get_contents()函数将整个文件读入一个字符串: string file_get_contents ( string filename [, bool use_include_path [, resource context [, int offset [, int maxlen]]]] ) 第6章目录 */180 6.1 文件操作 6.1.5 文件定位 fseek()函数在文件中定位文件指针: int fseek ( resource handle, int offset [, int whence] ) rewind()函数将文件指针设置到文件开头: bool rewind ( resource handle ) ftell()函数返回文件指针读/写的位置: int ftell ( resource handle ) feof()函数测试文件指针是否到了文件结束的位置: bool feof ( resource handle ) 第6章目录 */180 6.1 文件操作 6.1.6 检查文件属性 fileatime()函数取得文件的上次访问时间: int fileatime ( string filename ) filectime()函数取得文件的创建时间: int filectime ( string filename ) filemtime()函数取得文件的修改时间: int filemtime ( string filename ) filesize()函数取得文件的大小: int filesize ( string filename ) filetype()函数取得文件的类型: string filetype ( string filename ) 第6章目录 */180 6.1 文件操作 6.1.7 重命名文件 用rename()函数对一个文件或目录进行重命名:

文档评论(0)

181****8523 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档