Answers for "php read write from file"

PHP
9

write to file php

$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
fwrite($myfile, "Content to write to file");
fclose($myfile);
Posted by: Guest on October-22-2020
1

php write file

<?php
$file = 'people.txt';
// Open the file to get existing content
$current = file_get_contents($file);
// Append a new person to the file
$current .= "John Smith\n";
// Write the contents back to the file
file_put_contents($file, $current);
?>
Posted by: Guest on February-06-2022

Browse Popular Code Answers by Language