PHP Simple implementation of the method of generating TXT file to the specified directory, _php tutorial

Source: Internet
Author: User
Tags getting started with php

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: ...

  • Large-Scale Price Reduction
    • 59% Max. and 23% Avg.
    • Price Reduction for Core Products
    • Price Reduction in Multiple Regions
    undefined. /
    Connect with us on Discord
    • Secure, anonymous group chat without disturbance
    • Stay updated on campaigns, new products, and more
    • Support for all your questions
    undefined. /
    Free Tier
    • Start free from ECS to Big Data
    • Get Started in 3 Simple Steps
    • Try ECS t5 1C1G
    undefined. /

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.