PHP simple implementation of generating TXT files to the specified directory method,
The example in this paper describes the simple implementation of PHP to generate a TXT file to the specified directory method. Share to everyone for your reference, as follows:
<?php//fopen The second parameter can be the following four, the difference is whether to empty the content and then add the content//"W" Write open, the file pointer to the file header and the file size is truncated to zero. If the file does not exist, try to create it. The "w+" read-write mode opens, pointing the file pointer to the file header and truncating the file size to zero. If the file does not exist, try to create it. The "A" write opens, pointing the file pointer to the end of the file. If the file does not exist, try to create it. A + read-write mode opens, pointing the file pointer to the end of the file. If the file does not exist, try to create it. $myfile = fopen ("C:/newfile.txt", "a") or Die ("Unable to open file!"); /This is the C packing directory generated file $txt = $_get;//get the parameter $b= ""; foreach ($txt as $k = = $v) { $b = $b. " [". $k."] = ". $v." \ n ";} $txt 1 = $_post;foreach ($txt 1 as $k = + $v) { $b = $b. " [". $k."] = ". $v." \ n ";} $b = $b. " 123 "; Fwrite ($myfile, $b);//write content, can write many times oh, but it doesn't make sense, because you are stitching good strings, a write on the line fclose ($myfile);//Close the Operation?>
Easy way and very useful
File_put_contents ("C:/zll.txt", "content");
More about PHP related content readers can view the topic: "PHP File Operation Summary", "PHP operation and operator Usage Summary", "PHP Network Programming Skills Summary", "PHP Basic Grammar Introductory Tutorial", "PHP operation Office Document tips summary (including word, excel,access,ppt), "PHP Date and Time usage summary", "PHP primer for Object-oriented programming", "PHP String Usage Summary", "Getting Started with Php+mysql database operations" and "PHP Common Database Operations Skills Summary"
I hope this article is helpful to you in PHP programming.
http://www.bkjia.com/PHPjc/1123843.html www.bkjia.com true http://www.bkjia.com/PHPjc/1123843.html techarticle PHP Simple implementation of the method of generating TXT files to the specified directory, this article describes the simple implementation of PHP to generate a TXT file to the specified directory method. Share to everyone for your reference, as follows: ...