用PHP建立txt文件,并写入文字内容

<!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>

效果,在stiterm文件夹自动建立了一个newfile.txt文件夹,里面的内容是

Bill Gates
Steve Jobs

猜你喜欢

转载自blog.csdn.net/weixin_40945354/article/details/108423581
今日推荐