Home >Backend Development >PHP Problem >What does fputs mean in php

What does fputs mean in php

藏色散人
藏色散人Original
2021-12-07 09:51:293588browse

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.

What does fputs mean in php

#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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn