PHP fputs() Function
Definition and Usage
The fputs() function writes to a file (can be safely used for binary files).
The fputs() function is fwrite() Alias of the function.
Syntax
fputs(file,string,length)
Parameters | Description |
---|---|
file | Required. Specifies the file to be written to. |
string | Required. Specifies the string to be written to the file. |
length | Optional. Specifies the maximum number of bytes to be written. |
Description
fwrite() writes string the content to be written to the file pointer file . If specified lengthwhen written length bytes or until it is finished string From then on, writing will stop, depending on which condition is encountered first.
fwrite() returns the number of characters written, or false if an error occurs.
Example
<?php $file = fopen("test.txt","w"); echo fputs($file,"Hello World. Testing!"); fclose($file); ?>
Output:
21