Write to a file

fwrite() function

<?php
$filename = "example.txt";
$file = fopen($filename, "w") or die("Unable to open file!");
$text = "Hello, World!";
fwrite($file, $text);
fclose($file);
echo "Data written to $filename successfully.";
?>

Leave a Reply

Your email address will not be published. Required fields are marked *