PHP fwrite() Function

P
PHP glob() Function
PHP ftruncate() Function

In this article, you will learn how to write in file in PHP. The fwrite() function in PHP writes to an open file.

what is the syntax of the FWRITE function in php?

fwrite(file, string, length)
ParameterDescription
fileRequired. Specifies the open file to write to
stringRequired. Specifies the string to write to the open file
lengthOptional. Specifies the maximum number of bytes to write
PHP fwite() method

examples of the FWRITE function

Example 1. In this example, we write to an open file.

<?php
$file = fopen("test.txt","w");
echo fwrite($file,"Hello World. Testing!");
fclose($file);
?>
PHP glob() Function
PHP ftruncate() Function

Add comment

Tutor Network

Share this

Learn PHP from A to Z