Write to an open file:
<?php
$file = fopen("test.txt","w");
echo fwrite($file,"Hello World. Testing!");
fclose($file);
?>
The output of the code above will be:
21
The fwrite() writes to an open file.
The function will stop at the end of the file (EOF) or when it reaches the specified length, whichever comes first.
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 |
Return Value: | The number of bytes written, FALSE on failure |
---|---|
PHP Version: | 4.0+ |
Binary Safe: | Yes |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!