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]