写入打开的文件:
<?php
$file = fopen("test.txt","w");
echo fwrite($file,"Hello World. Testing!");
fclose($file);
?>
上面代码的输出将是:
21
fwrite() 写入打开的文件。
该函数将在文件末尾 (EOF) 或达到指定长度时停止,以先到者为准。
fwrite(
file,
string,
length)
Parameter | Description |
---|---|
file | Required. Specifies the open file to write to |
string | Required. Specifies the string to write to the open file |
length | Optional. Specifies the maximum number of bytes to write |
返回值: | 写入的字节数,失败时为 FALSE |
---|---|
PHP 版本: | 4.0+ |
二进制安全: | 是的 |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!