The fputs() writes to an open file.
The fputs() function is an alias of the fwrite() function.
PHP fputs() Function has the following syntax.
fputs(file,string,length)
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 |
This function returns the number of bytes written on success, or FALSE on failure.
<?php
$file = fopen("test.txt","w");
echo fputs($file,"Hello World from java2s.com!");
fclose($file);
?>
The code above generates the following result.