2026-10-29 19:19:58
有两种方法:
file_put_contents("/tmp/a.txt","");
system("cd /tmp; touch 1.txt"); 这种只时候在服务器执行,本地不可以
2026-01-03 01:12:46
看手册,文件操作部分,比如 file_put_contents 就能满足要求
<?php
$file = 'people.txt';
// The new person to add to the file
$person = "John Smith\n";
// Write the contents to the file,
// using the FILE_APPEND flag to append the content to the end of the file
// and the LOCK_EX flag to prevent anyone else writing to the file at the same time
file_put_contents($file, $person, FILE_APPEND | LOCK_EX);
?>
2026-06-17 00:52:46