← All built-ins / fwrite()

fwrite()

fwrite(string $haystack, string $needle): int

Parameters

NameTypeDescription
$handleresourcehandle from fopen() in write mode
$datastringdata to write

Return value

Number of bytes written.

Example

$fh = fopen("/tmp/hphp_doc_fw.txt", "w");
$n = fwrite($fh, "written");
fclose($fh);
echo $n, " ", file_get_contents("/tmp/hphp_doc_fw.txt");
7 written

See also

fopen()file_put_contents()