PHP file write functions are given below:
1.PHP fwrite() Function
The fwrite() writes to an open file.it will stop at the end of the file (EOF) or when it reaches the specified length.
Syntax for fwrite() Function
fwrite(file, string, length)
Parameter Description
file Specifies the open file to write to
string Specifies the string to write to the open file
length Specifies the maximum number of bytes to write
<?php
$file = fopen("myfile.txt","w");
echo fwrite($file,"Hello World. Welcome to bajarangisoft!");
fclose($file);
?>
<!DOCTYPE html>
<html>
<head>
<title>What are the different functions used to write file in PHP</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<br>
<br>
<br>
<div class="text-center">
<h1>PHP Write a file in different Function</h1>
</div>
<br>
<br>
<h2></h2>
<div class="well">
<?php
$file = fopen("myfile.txt","w");
echo "<h1>".fwrite($file,"Hello World. Welcome to bajarangisoft!")."</h1>";
fclose($file);
?>
</div>
<br>
</div>
</body>
</html>