The example in this article describes how the PHP export generates word. Share to everyone for your reference, specific as follows:
PHP Export Word
(1) First, preview the HTML page, sample the object, define the data to be exported
(2) Click on the download page, to the ID pass value (any value can be used only for judgment), if the ID has a value, output buffer file, save in Word format.
(3) Click on the download, (if it is a picture, when saving as word to use the absolute path, so that you can in the saved word normal display)
(4) Turn off the cache output
word_con.php preview of HTML files to export
<?php
if (@$_get[id]!= ')
{
include (' word_fun.php ');
$word =new Word ()///The Sample object
$word->start ();//define the start of the data to be saved
}
include (' word_show.php ');
if (@$_get[id]!= ')
{
$word->save (' Word_c.doc ');//define the end of the data to be saved and save the data to
word
(@$_get[ id]== ')
{
//hyperlink x is just to pass a value, confirm the download, no other actual Yi
?>
<a href= "#" ><div onclick= " window.location.href= ' word_con.php?id=x ' > click to jump to download page </div></a>
<?php
}else{
echo "<a href=\" word_c.doc\ "> Download </a>";
>
word_fun.php export word-related functions
<?php
class word
{
function start ()//define the beginning of the data to be saved
{
ob_start ();//Start output buffer
//Set format for word generation
print '
I hope this article will help you with the PHP program design.