Compose anything to a file that is open:
<?php $file = fopen(“test.txt”,“w”); echo fwrite($file,“Hello World. Testing!”); fclose($file); ?> |
The following is the result of the code above:
21 |
To an open file, the fwrite() writes.
When the function reaches the designated length or the end of the file (EOF), whichever comes first, it will terminate.
fwrite(file, string, length) |
Parameter |
Description |
file |
Essential. The open file to write to is specified. |
string |
Essential. gives the string that should be written to the open file. |
length |
Not required. indicates the most bytes that can be written. |
Return Value: |
The amount of bytes written; if an error occurs, FALSE |
PHP Version: |
4.0+ |
Binary Safe: |
Yes |