PHP fputs() function
Definition and Usage
fputs() function writes to the file (can be safely used for binary files).
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 write. |
Description
fwrite() writes string the content is written to the file pointer file at. If specified lengthwhen written length bytes or finished writing string Later, writing will stop, depending on which condition occurs 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