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

小竣 日常收集2,506阅读模式

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

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


<?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);
?>

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

Bill Gates
Steve Jobs

weinxin
我的微信
我的微信
微信扫一扫