php file_put_contents()函数

php中文网
发布: 2016-05-19 12:15:10
原创
1502人浏览过

 definition and usage  定义和用法

ExcelFormulaBot
ExcelFormulaBot

在AI帮助下将文本指令转换为Excel函数公式

ExcelFormulaBot 206
查看详情 ExcelFormulaBot
The file_put_contents() writes a string to a file.
file_put_contents()函数的作用是:将一个字符串写入文件。
This function follows these rules when accessing a file:  当访问一个文件是,函数必须遵循下面这些法则:
  1. If FILE_USE_INCLUDE_PATH is set, check the include path for a copy of *filename* 
    如果设置了FILE_USE_INCLUDE_PATH,那么将检查*filename*副本的内置路径
  2. Create the file if it does not exist 
    如果文件不存在,将创建一个文件
  3. Open the file 
    打开文件
  4. Lock the file if LOCK_EX is set 
    如果设置了LOCK_EX,那将对文件上锁
  5. If FILE_APPEND is set, move to the end of the file. Otherwise, clear the file content 
    如果设置了FILE_APPEND,那么将移至文件末尾;否则的话,将会清除文件的内容
  6. Write the data into the file 
    向文件中写入数据
  7. 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。
Syntax
语法
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是一组选项,你可以通过它修改你的文本属性
1 2  下一页
PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号