php 如何创建txt文件
发布网友
发布时间:2023-11-27 01:02
我来回答
共3个回答
热心网友
时间:2024-07-18 04:25
有两种方法:
file_put_contents("/tmp/a.txt","");
system("cd /tmp; touch 1.txt"); 这种只时候在服务器执行,本地不可以
热心网友
时间:2024-07-18 04:26
看手册,文件操作部分,比如 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);
?>
热心网友
时间:2024-07-18 04:26
<?php
$file = fopen("a.text",'w');
fwrite($file,"sdadsadasdas");
fclose($file);
?>