PHP fputs() Function
Definition
The fputs() writes to an open file.
The fputs() function is an alias of the fwrite() function.
Syntax
PHP fputs() Function has the following syntax.
fputs(file,string,length)
Parameter
Parameter | Is Required | Description |
---|---|---|
file | Required. | Open file to write to |
string | Required. | String to write to the open file |
length | Optional. | Maximum number of bytes to write |
Return
This function returns the number of bytes written on success, or FALSE on failure.
Example
<?php//from w w w . ja va 2 s. c o m
$file = fopen("test.txt","w");
echo fputs($file,"Hello World from java2s.com!");
fclose($file);
?>
The code above generates the following result.