fputs
alias for fwrite
The fputs()
function is written to a file (safely used in binary files).
fputs()
function is an alias for the fwrite()
function.
<?php $file = fopen ( "test.txt" , "w" ) ; echo fputs ( $file , "Hello World. Testing!" ) ; fclose ( $file ) ; ?>
Output:
twenty one
fputs ( file , string , length )
parameter | describe |
---|---|
file | Required. Specifies the open file to be written. |
string | Required. Specifies the string to be written to the file. |
length | Optional. Specifies the maximum number of bytes to be written. |
fwrite()
writes the contents of string to the file pointer file . If length is specified, the writing will stop when length bytes are written or string is finished, depending on which situation is encountered first.
fwrite()
returns the number of characters written, and returns false when an error occurs.