Home >Backend Development >PHP Tutorial >PHP realizes converting html to word and doc
$title
=
"PHP generates doc file"
;
$html
=
'<h1>PHP generates doc files - Laoba Blog</h1>
<p>PHP generates <strong>word documents</strong> in doc format is relatively simple,
The main thing is to note that it is easy to make mistakes when creating files with Chinese names. Just use iconv to convert them before creation.
The main thing is to note that it is easy to make mistakes when creating files with Chinese names. Just use iconv to convert them before creating them.</p>
<p>The usage method is relatively simple.
Just output it directly: <strong></strong>echo
$data
,
filename) </p>
<p>The method of use is relatively simple,
Just output it directly:
echo
$data
,
filename) </p>
<p>This program is written by<a
href=
"http://www.lao8.org"
//How to use-------------------------
echo
$html
"UTF-8"
"
GB2312//IGNORE"
,
$title
)));
//Convert to Chinese and ignore errors
//------------------------------------- ---<strong></strong>
function
$data
$fileName
''
)
{
if
(
(
))
return
''
;
$ data
=
.
.
'</html>'
;
. "
.
date
(
"Ymd"
"/"
;
file_exists
(
$dir
))
mkdir
(
$dir
,777,true);
($fileName
))
{
).
'.doc'
;
}
else
{
.
$fileName
'.doc'
;
}
fileName
,
'wb'
or
die
"Failed to create file"
);
$writefile
,
$data
);
fclose(
$writefile
);
The above has introduced the PHP implementation of converting HTML to word and doc, including word documents and GB2312 content. I hope it will be helpful to friends who are interested in PHP tutorials. <p>
</p>