← All built-ins / file_put_contents()
file_put_contents()
file_put_contents(...$args): int
Parameters
| Name | Type | Description |
|---|---|---|
| $path | string | file path |
| $data | string | content to write |
| $flags | int | PHP_FILE_APPEND to append instead of truncatingoptional |
Return value
Number of bytes written.
Example
$n = file_put_contents("/tmp/hphp_doc_demo2.txt", "line1\n");
file_put_contents("/tmp/hphp_doc_demo2.txt", "line2", PHP_FILE_APPEND);
echo $n, "\n", file_get_contents("/tmp/hphp_doc_demo2.txt"), "
";6 line1 line2