Php generates the txt file title and content

Source: Internet
Author: User
Welcome to the Linux community forum and interact with 2 million technical staff to enter the title and content of the txt file generated by php. The code is attached :? Php *** 1. when a buddy worked a few days ago, they asked him to write a file generation class: generate a file. The file types include txt, html, csv, pdf, doc (or docx ). ** 2. The generated content is

Welcome to the Linux community forum and interact with 2 million technical staff> go to php to generate the title and content of the txt file. The code is attached :? Php/*** 1. when a buddy worked a few days ago, they asked him to write a file generation class: generate a file. The file types include txt, html, csv, pdf, doc (or docx ). ** 2. The generated content is

Welcome to the Linux community forum and interact with 2 million technicians>

The title and content of the txt file generated by php are included in the Code:

  

/**

* 1. when a buddy worked a few days ago, they asked him to write a file generation class: generate a file. The file types include txt, html, csv, pdf, doc (or docx ).

*

* 2. the generated content is a table (like a table in html). The parameter is the file type generated, the title of the generated content (array), and the generated content (array, corresponding to the title ).

*/

/*************************************** **********

* Class name: createFile

* Description: create different type files

* Author: fenghuo

* Date: 2013-11-12

**************************************** ********/

/**

* 3. I used the evening time to help him sort out a txt file class.

***/

Class createFile {

Public $ file_type;

Public $ file_name;

Public $ file_dir;

/**

* Constructor: Initialize the directory of the generated file

*/

Public function _ construct ($ file_dir ){

$ This-> file_dir = $ file_dir;

}

/**

* File generation portal Function

* @ String $ file_name file name

* @ String $ file_type file type

* @ Array $ title: The title line of the content generated

* @ Array $ data Generated Content

*/

Public function create_file ($ file_name, $ file_type, $ title, $ data ){

If (empty ($ data )){

Return false;

}

If (! Empty ($ title )){

If (count ($ title )! = Count ($ data [0]) {

Return false;

}

}

If ($ file_name = ""){

$ File_name = $ this-> file_name;

}

If ($ file_type = ""){

$ File_type = $ this-> file_type;

}

$ Fun = 'mk _ '. $ file_type;

# Test Point

Echo $ fun ,'--------------
';

If (method_exists ($ this, $ fun ))

{

[1] [2]

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.