Create a txt file with PHP and write text content

<!DOCTYPE html>
<html>

<body>

<?php
$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
$txt = "Bill Gates\n";
fwrite($myfile, $txt);
$txt = "Steve Jobs\n";
fwrite($myfile, $txt);
fclose($myfile);
?>
 
</body></html>

As a result, a newfile.txt folder is automatically created in the stiterm folder, and the content inside is

Bill Gates
Steve Jobs

Guess you like

Origin blog.csdn.net/weixin_40945354/article/details/108423581