Home  >  Article  >  Backend Development  >  PHP simply implements a method to generate txt files to a specified directory

PHP simply implements a method to generate txt files to a specified directory

高洛峰
高洛峰Original
2017-02-04 16:41:443266browse

The example in this article describes how to simply implement PHP to generate a txt file to a specified directory. Share it with everyone for your reference, the details are as follows:

$v){
  $b = $b ."[".$k."]=>".$v."\n";
}
$txt1 = $_POST;
foreach($txt1 as $k=>$v){
  $b = $b ."[".$k."]=>".$v."\n";
}
$b = $b."123";
fwrite($myfile, $b);//写入内容,可以写多次哦,不过没啥意义,因为你拼接好字符串,一次写入就行了
fclose($myfile);//关闭该操作
?>

A simple and useful method is

file_put_contents("c:/zll.txt","内容");

I hope this article will be helpful to everyone in PHP programming.

For more related articles on how to simply generate txt files to a specified directory using PHP, please pay attention to the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn