PHP fputs() Function
Complete PHP Filesystem Reference Manual
Definition and Usage
The fputs() function writes content to an open file.
The function stops when it reaches the specified length or the end of file (EOF), whichever comes first.
Returns the number of bytes written on success, or FALSE on failure.
The fputs() function is an alias of fwrite().
Syntax
fputs(file,string,length)
| Parameters | Description |
|---|---|
| file | Required. Specifies the open file to write to. |
| string | Required. Specifies the string to write to the open file. |
| length | Optional. Specifies the maximum number of bytes to write. |
Tips and Notes
**Tip:** This function is binary-safe (meaning both binary data, such as images, and character data can be written with this function).
Example
The code above will output:
21
Complete PHP Filesystem Reference Manual