文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>file_put_contents()

file_put_contents()

时间:2007-01-20  来源:mosquito_2006


file_put_contents()函数定义和用法
The file_put_contents() writes a string to a file.
file_put_contents()函数的作用是:将一个字符串写入文件。
This function follows these rules when accessing a file:
当访问一个文件是,函数必须遵循下面这些法则:
  • If FILE_USE_INCLUDE_PATH is set, check the include path for a copy of *filename*
    如果设置了FILE_USE_INCLUDE_PATH,那么将检查*filename*副本的内置路径
    • Create the file if it does not exist
      如果文件不存在,将创建一个文件
    • Open the file
      打开文件
    • Lock the file if LOCK_EX is set
      如果设置了LOCK_EX,那将对文件上锁
    • If FILE_APPEND is set, move to the end of the file. Otherwise, clear the file content
      如果设置了FILE_APPEND,那么将移至文件末尾;否则的话,将会清除文件的内容
    • Write the data into the file
      向文件中写入数据
    • Close the file and release any locks
      关闭文件并对所有文件解锁
      This function returns the number of character written into the file on success, or FALSE on failure.
      如果函数运行成功,将返回写入文件中的字符数量;如果失败,则返回False。
      file_put_contents(file,data,mode,context)
      Parameter
      参数
      Description
      描述
      file
      Required. Specifies the file to write to. If the file does not exist, this function will create one
      必要参数。指定写入文件对象。如果该文件不存在,函数将自动创建该文件
      data
      Required. The data to write to the file. Can be a string, an array or a data stream
      必要参数。指定写入文件的数据,可以使一个字符串或者是一个数组
      mode
      Optional. Specifies how to open/write to the file. Possible values:
      可选参数。指定打开/书写文件的方法:

      • FILE_USE_INCLUDE_PATH
      • FILE_APPEND
      • LOCK_EX

      context
      Optional. Specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream.
      可选参数。指定需要进行处理的文件context[内容]。Context是一组选项,你可以通过它修改你的文本属性


  • 相关阅读 更多 +
    排行榜 更多 +
    边境警察巡逻模拟中文版下载

    边境警察巡逻模拟中文版下载

    角色扮演 下载
    数码宝贝世界复原手机版下载

    数码宝贝世界复原手机版下载

    角色扮演 下载
    土地抢夺者中文手机版下载

    土地抢夺者中文手机版下载

    策略塔防 下载