← All built-ins / fopen()
fopen()
fopen(string $haystack, string $needle): mixed
Parameters
| Name | Type | Description |
|---|---|---|
| $path | string | file path |
| $mode | string | "r" read, "w" truncate+write, "a" append; add "b" for binary |
Return value
File handle for fgets/fread/fwrite/fclose, or false on failure.
Example
$fh = fopen("/tmp/hphp_doc_fh.txt", "w");
fwrite($fh, "streamed");
fclose($fh);
echo file_get_contents("/tmp/hphp_doc_fh.txt");streamed