Home > Article > Backend Development > What does fputs mean in php
fputs in php is a function used to write files, and the fputs function is an alias of the fwrite function. Its usage syntax is "fputs(file, string, length)", and the parameter file specifies what to write. to open the file.
#The operating environment of this article: Windows 7 system, PHP version 7.4, Dell G3 computer.
What does fputs mean in php?
fputs() function writes to a file (safe for use with binary files).
fputs() function is an alias of fwrite() function.
Syntax
fputs(file,string,length)
Parameters
file required. Specifies the open 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 be written.
Description
fwrite() writes the contents of string to the file pointer file. If length is specified, writing will stop when length bytes have been written or when the string has been written, whichever 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
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What does fputs mean in php. For more information, please follow other related articles on the PHP Chinese website!