$file = 'file.txt';
$content = 'Hello, world!';
file_put_contents($file, $content);
$file = 'file.txt';
$content = 'Hello, world!';
$handle = fopen($file, 'w');
fwrite($handle, $content);
fclose($handle);
$file = 'file.txt';
$content = 'Hello, world!';
file_put_contents($file, $content, FILE_APPEND);
$file = 'file.txt';
$content = 'Hello, world!';
$handle = fopen($file, 'a');
fwrite($handle, $content);
fclose($handle);
$file = 'file.txt';
$content = 'Hello, world!';
file_put_contents($file, $content, LOCK_EX);
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
相关推荐:php写入文件内容的方法有哪些