PHP fwrite() 函数

PHP 教程 · 2019-01-25 09:29:19

定义和用法

fwrite() 函数将内容写入一个打开的文件中。

函数会在到达指定长度或读到文件末尾(EOF)时(以先到者为准),停止运行。

如果函数成功执行,则返回写入的字节数。如果失败,则返回 FALSE。

语法


fwrite(file,string,length)


参数 描述
file 必需。规定要写入的打开文件。
string 必需。规定要写入打开文件的字符串。
length 可选。规定要写入的最大字节数。

提示和注释

提示:该函数是二进制安全的。(意思是二进制数据(如图像)和字符数据都可以使用此函数写入。)

实例


<?php
$file = fopen("test.txt","w");
echo fwrite($file,"Hello World. Testing!");
fclose($file);
?> 

上面的代码将输出:


21


点击查看所有 PHP 教程 文章: https://www.codercto.com/courses/l/5.html

查看所有标签

DOM Scripting

DOM Scripting

Jeremy Keith / friendsofED / 2010-12 / GBP 27.50

There are three main technologies married together to create usable, standards-compliant web designs: XHTML for data structure, Cascading Style Sheets for styling your data, and JavaScript for adding ......一起来看看 《DOM Scripting》 这本书的介绍吧!

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具