Question : write to file php
Answered by : thoughtful-termite-tmm6vqv8qoxh
$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
fwrite($myfile, "Content to write to file");
fclose($myfile);
Source : | Last Update : Thu, 29 Oct 20
Question : php write to file
Answered by : emircan
$text = "Anything";
$var_str = var_export($text, true);
file_put_contents('filename.txt', $var_str);
Source : | Last Update : Mon, 22 Aug 22
Question : write file in php
Answered by : kinjal-suryavanshi
// if not file is there then automatic create and write inside it.
$fptr = fopen('myfile.txt','w');
fwrite($fptr,"i am writing file in this\n");
fwrite($fptr,'writing another line.');
fclose($fptr);
Source : | Last Update : Tue, 19 Oct 21
Question : php write file
Answered by : nilsgoeke
<?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);
?>
Source : https://www.php.net/manual/en/function.file-put-contents.php | Last Update : Sun, 13 Feb 22
Question : write in a file using php
Answered by : ankur-prajapati
<?php
$myfile = fopen("file_name.txt", "w") or die("Unable to open file!");
$txt = "Hello world\n";
fwrite($myfile, $txt);
$txt = " Php.\n";
fwrite($myfile, $txt);
fclose($myfile);
?>
Source : | Last Update : Fri, 12 Jun 20