Introduction: This is a detailed page for PHP output and CSV writing. It introduces the related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 337308 'rolling = 'no'>
1. First, use the header () in PHP.
For more information, see the PHP header () function and P in w3school.HPMediumEnableUseHEADERLetterQuantityOfHTTPHeaderSetSet.
The Header () function must be called before any actual output is sent.
Below is a CSV sample output in PHP.
1. Define the header output format
Header ("Content-Type: Application/vnd. MS-excel"); // defines the output file type
Header ("Content-Disposition: filename =downloaded.pdf
"); // Define the output file name, that is, set a download type. The file is renamed during download.
<? PHP
Header ("Content-Type: Application/vnd. MS-excel ");
Header ("content-Disposition: filenameappsdownloaded.pdf ");
Echo "1 \ t 2 \ t 3 \ n"; // where \ t is blank and \ n is carriage return (encoding specifications cannot be output directly)
Echo "1 \ t 2 \ t 3 \ n ";
Echo "1 \ t 2 \ t 3 \ n ";
?>
In this case, you can open the PHP file and a prompt will be displayed for download.
It can also be output as a table;
<? PHP
Header ("Content-Type: Application/vnd. MS-excel ");
Header ("content-Disposition: filenameappsdownloaded.pdf ");
?>
<Table>
<Tr>
<TD> t00 </TD> <TD> t01 </TD> <TD> t02 </TD>
</Tr>
<Tr>
<TD> T10 </TD> <TD> T11 </TD> <TD> T12 </TD>
</Tr>
<Tr>
<TD> T20 </TD> <TD> T21 </TD> <TD> T22 </TD>
</Tr>
</Table>
CSV write operation:
For use of fputcsv (), refer.
$ Fp = fopen ('f:/file.csv ', 'w ');
Fputcsv ($ FP, array ('aaa', 'bbb ', 'cccccc '));
Fputcsv ($ FP, array ('mmm', 'yyy', 'hahaha'); // fputcsv () can be implemented using array loops.
Fclose ($ FP );
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/337308.html pageno: 9.