PHP fwrite() Function

Write to an open file

Definition and Usage

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.

Syntax

fwrite(file, string, length)

Parameter Values

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

Technical Details

Return Value: The number of bytes written, FALSE on failure
PHP Version: 4.0+
Binary Safe: Yes

❮ PHP Filesystem Reference