fwriteBinary-safe file write
&reftitle.description;
intfwriteresourcehandlestringstringintlengthfwrite writes the contents of
string to the file stream pointed to by
handle.
&reftitle.parameters;
handle
&fs.file.pointer;
string
The string that is to be written.
length
If the length argument is given, writing will
stop after length bytes have been written or
the end of string is reached, whichever comes
first.
Note that if the length argument is given,
then the magic_quotes_runtime
configuration option will be ignored and no slashes will be
stripped from string.
&reftitle.returnvalues;
fwrite returns the number of bytes
written, or &false; on error.
&reftitle.notes;
Writing to a network stream may end before the whole string is written.
Return value of fwrite may be checked:
]]>
On systems which differentiate between binary and text files
(i.e. Windows) the file must be opened with 'b' included in
fopen mode parameter.
If handle was fopened in
append mode, fwrites are atomic (unless the size of
string exceeds the filesystem's block size, on some
platforms, and as long as the file is on a local filesystem). That is,
there is no need to flock a resource before calling
fwrite; all of the data will be written without
interruption.
If writing twice to the file pointer, then the data will be appended to
the end of the file content:
]]>
&reftitle.examples;
A simple fwrite example
]]>
&reftitle.seealso;
freadfopenfsockopenpopenfile_get_contents