The fputs() function writes the contents to an open file.
The function will stop running when it reaches the specified length or reaches the end of file (EOF), whichever comes first.
If the function executes successfully, the number of bytes written is returned. If it fails, returns FALSE.
The fputs() function is an alias for the fwrite() function.
fputs(file,string,length)
parameter | describe |
---|---|
file | Required. Specifies the open file to write to. |
string | Required. Specifies the string to be written to the open file. |
length | Optional. Specifies the maximum number of bytes to be written. |
Tip: This function is binary safe. (Meaning that both binary data (such as images) and character data can be written using this function.)
<?php$file = fopen("test.txt","w");echo fputs($file,"Hello World. Testing!");fclose($file);?>
The above code will output:
twenty one